29 #ifndef AURORA_VARIADIC_HPP
30 #define AURORA_VARIADIC_HPP
36 #ifdef AURORA_HAS_VARIADIC_TEMPLATES
41 template <
typename... Ts>
48 template <
typename T,
typename... Types>
51 template <
typename T,
typename Head,
typename... Tail>
52 struct IndexOfType<T, Head, Tail...>
54 static const std::size_t value = 1 + IndexOfType<T, Tail...>::value;
57 template <
typename T,
typename... Tail>
58 struct IndexOfType<T, T, Tail...>
60 static const std::size_t value = 0;
65 template <
typename Function,
typename... Ts>
68 template <
typename Function,
typename T,
typename... Ts>
69 struct ForEachType<Function, T, Ts...>
71 static void apply(Function&& fn)
78 fn.template operator()<T>();
80 ForEachType<Function, Ts...>::apply(std::forward<Function>(fn));
84 template <
typename Function>
85 struct ForEachType<Function>
87 static void apply(Function&& )
93 template <
typename Function,
typename... Ts>
94 struct ForEachType<Function, Typelist<Ts...>> : ForEachType<Function, Ts...>
100 template <
typename Function,
typename... Ts>
103 template <
typename Function,
typename T,
typename... Ts>
104 struct ForEachValue<Function, T, Ts...>
106 static void apply(Function&& fn, T&& t, Ts&&... ts)
108 fn(std::forward<T>(t));
109 ForEachValue<Function, Ts...>::apply(std::forward<Function>(fn), std::forward<Ts>(ts)...);
113 template <
typename Function>
114 struct ForEachValue<Function>
116 static void apply(Function&& )
133 template <
typename... Ts>
141 template <
typename Types, std::
size_t Index>
144 template <
typename Head,
typename... Tail, std::size_t Index>
150 template <
typename Head,
typename... Tail>
159 template <
typename Types,
typename Searched>
162 template <
typename Head,
typename... Tail,
typename Searched>
168 template <
typename Head,
typename... Tail>
171 static const std::size_t value = 0u;
177 template <
typename LhsTypelist,
typename RhsTypelist>
180 template <
typename... Ts,
typename... Us>
189 template <
typename Typelist1,
typename T>
192 template <
typename U,
typename... Us,
typename T>
195 static const bool value =
199 template <
typename T>
202 static const bool value =
false;
222 template <
typename... Ts,
typename Function>
223 void foreach(Function&& fn)
225 detail::ForEachType<Function, Ts...>::apply(std::forward<Function>(fn));
245 template <
typename... Ts,
typename Function>
246 void foreach(Function&& fn, Ts&&... args)
248 detail::ForEachValue<Function, Ts...>::apply(std::forward<Function>(fn), std::forward<Ts>(args)...);
255 #endif // AURORA_HAS_VARIADIC_TEMPLATES
256 #endif // AURORA_VARIADIC_HPP
Concatenate two typelists.
Definition: Variadic.hpp:178
Check if type is part of typelist.
Definition: Variadic.hpp:190
Simple type wrapper, can be used for overload resolution.
Definition: Templates.hpp:120
Configuration header of the library.
Random access to type.
Definition: Variadic.hpp:142
Find position of type in typelist.
Definition: Variadic.hpp:160
Class template to store a list of types.
Definition: Variadic.hpp:42
Definition: DispatchTraits.hpp:39