dune-common  2.5-git
typelist.hh
Go to the documentation of this file.
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>
116 
117 
118 } // namespace Dune
119 
120 #endif // DUNE_COMMON_TYPELIST_HH
Check if given type is an empty TypeList.
Definition: typelist.hh:65
A simple type list.
Definition: typelist.hh:30
Dune namespace.
Definition: alignment.hh:10
typename TypeListElement< i, T >::type TypeListEntry_t
Shortcut for TypeListElement<i, T>::type;.
Definition: typelist.hh:115
Definition: typelist.hh:70
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
Definition: typelist.hh:86
type Type
Export type of i-th element in TypeList.
Definition: typelist.hh:108