Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
is_iterable.h
浏览该文件的文档.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <sese/types/defines.h>
18
19namespace sese {
20
21template<typename T, typename = void>
22struct has_begin : std::false_type {}; // NOLINT
23
24template<typename T>
25struct has_begin<T, void_t<decltype(std::declval<T>().begin())>> : std::true_type {};
26
27template<typename T, typename = void>
28struct has_end : std::false_type {}; // NOLINT
29
30template<typename T>
31struct has_end<T, void_t<decltype(std::declval<T>().begin())>> : std::true_type {};
32
33template <typename T>
34struct is_iterable : std::conjunction<has_begin<T>, has_end<T>> {}; // NOLINT
35
36template <typename T>
37constexpr bool is_iterable_v = is_iterable<T>::value; // NOLINT
38
39} // namespace sese