GrPPI  1.0
Generic and Reusable Parallel Pattern Interface
iterator_traits.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Universidad Carlos III de Madrid
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef GRPPI_COMMON_ITERATOR_TRAITS_H
17 #define GRPPI_COMMON_ITERATOR_TRAITS_H
18 
19 namespace grppi{
20 
21 namespace internal {
22 
23 template<typename T, typename = void>
25 {
26  static constexpr bool value = false;
27 };
28 
29 template<typename T>
30 struct is_iterator<T, typename std::enable_if<!std::is_same<typename std::iterator_traits<T>::value_type, void>::value>::type>
31 {
32  static constexpr bool value = true;
33 };
34 
35 template<typename T, typename ...other_T>
37 {
38  static constexpr bool value = is_iterator<T>::value && are_iterators<other_T...>::value;
39 };
40 
41 template<typename T>
42 struct are_iterators<T>
43 {
44  static constexpr bool value = is_iterator<T>::value;
45 };
46 
47 }
48 
49 template <typename T>
51 
52 template <typename T>
53 using requires_iterator = std::enable_if_t<is_iterator<T>, int>;
54 
55 template<typename ...T>
56 constexpr bool are_iterators = internal::are_iterators<T...>::value;
57 
58 template<typename ...T>
59 using requires_iterators = std::enable_if_t<are_iterators<T...>, int>;
60 
61 }
62 
63 #endif
Definition: callable_traits.h:21
std::enable_if_t< is_iterator< T >, int > requires_iterator
Definition: iterator_traits.h:53
std::enable_if_t< are_iterators< T... >, int > requires_iterators
Definition: iterator_traits.h:59
constexpr bool is_iterator
Definition: iterator_traits.h:50
constexpr bool are_iterators
Definition: iterator_traits.h:56
Definition: iterator_traits.h:37
static constexpr bool value
Definition: iterator_traits.h:38
Definition: iterator_traits.h:25
static constexpr bool value
Definition: iterator_traits.h:26