Dune Core Modules (2.6.0)

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
10namespace Dune {
11
30 template<class T>
31 struct MetaType {
33 using type = T;
34 };
35
84 template<class... T>
85 using TypeList = std::tuple<MetaType<T>...>;
86
87
88
97 template<class T>
98 struct IsTypeList : std::false_type {};
99
105 template<class... T>
106 struct IsTypeList<TypeList<T...> > : std::true_type {};
107
108
109
118 template<class T>
119 struct IsEmptyTypeList : std::is_same<T, TypeList<> > {};
120
121
122
123 template<class T>
124 struct TypeListSize {};
125
134 template<class... T>
135 struct TypeListSize<TypeList<T...>> : std::integral_constant<std::size_t, sizeof...(T)> {};
136
137
138
139 template<std::size_t i, class T>
140 struct TypeListElement {};
141
147 template<std::size_t i, class... T>
148 struct TypeListElement<i, TypeList<T...>>
149 {
155 using type = typename std::tuple_element<i, std::tuple<T...>>::type;
156
162 using Type = type;
163 };
164
168 template<std::size_t i, class T>
169 using TypeListEntry_t = typename TypeListElement<i, T>::type;
170
171
172} // namespace Dune
173
174#endif // DUNE_COMMON_TYPELIST_HH
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition: typelist.hh:85
Dune namespace.
Definition: alignedallocator.hh:10
typename TypeListElement< i, T >::type TypeListEntry_t
Shortcut for TypeListElement<i, T>::type;.
Definition: typelist.hh:169
Check if given type is an empty TypeList.
Definition: typelist.hh:119
Check if given type is a TypeList.
Definition: typelist.hh:98
A type that refers to another type.
Definition: typelist.hh:31
T type
The referred-to type.
Definition: typelist.hh:33
typename std::tuple_element< i, std::tuple< T... > >::type type
Export type of i-th element in TypeList.
Definition: typelist.hh:155
type Type
Export type of i-th element in TypeList.
Definition: typelist.hh:162
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)