Dune Core Modules (2.5.2)

typelist.hh
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_COMMON_TYPELIST_HH
4 #define DUNE_COMMON_TYPELIST_HH
5 
6 #include <type_traits>
7 #include <tuple>
8 
9 
10 namespace Dune {
11 
29  template<class... T>
30  struct TypeList
31  {};
32 
33 
34 
43  template<class T>
44  struct IsTypeList : std::false_type {};
45 
51  template<class... T>
52  struct IsTypeList<TypeList<T...> > : std::true_type {};
53 
54 
55 
64  template<class T>
65  struct IsEmptyTypeList : std::integral_constant<bool, IsTypeList<T>() and std::is_same<T, TypeList<> >() > {};
66 
67 
68 
69  template<class T>
70  struct TypeListSize {};
71 
80  template<class... T>
81  struct TypeListSize<TypeList<T...>> : std::integral_constant<std::size_t, sizeof...(T)> {};
82 
83 
84 
85  template<std::size_t i, class T>
86  struct TypeListElement {};
87 
93  template<std::size_t i, class... T>
94  struct TypeListElement<i, TypeList<T...>>
95  {
101  using type = typename std::tuple_element<i, std::tuple<T...>>::type;
102 
108  using Type = type;
109  };
110 
114  template<std::size_t i, class T>
115  using TypeListEntry_t = typename TypeListElement<i, T>::type;
116 
117 
118 } // namespace Dune
119 
120 #endif // DUNE_COMMON_TYPELIST_HH
Dune namespace.
Definition: alignment.hh:11
typename TypeListElement< i, T >::type TypeListEntry_t
Shortcut for TypeListElement<i, T>::type;.
Definition: typelist.hh:115
Check if given type is an empty TypeList.
Definition: typelist.hh:65
Check if given type is a TypeList.
Definition: typelist.hh:44
typename std::tuple_element< i, std::tuple< T... > >::type type
Export type of i-th element in TypeList.
Definition: typelist.hh:101
type Type
Export type of i-th element in TypeList.
Definition: typelist.hh:108
A simple type list.
Definition: typelist.hh:31
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)