28template <
typename Tp,
typename Up>
31 static constexpr bool value =
sizeof(Tp) <
sizeof(Up);
41template <
typename Tp, Tp Value>
44 static constexpr Tp
value = Value;
49template <std::size_t Height,
typename Tp,
50 bool = std::is_class<Tp>::value && !std::is_final<Tp>::value>
56template <std::
size_t Height,
typename Tp>
64 template <
typename Up>
66 : value(std::forward<Up>(other))
69 Tp&
get() {
return value; }
70 Tp
const&
get()
const {
return value; }
76template <std::
size_t Height,
typename Tp>
82 template <
typename Up>
84 : Tp(std::forward<Up>(other))
87 Tp&
get() {
return *
this; }
88 const Tp&
get()
const {
return *
this; }
93template <
unsigned H,
typename T>
102template <
typename... Types>
108template <
typename Head,
typename... Tail>
110:
private TupleElt<sizeof...(Tail), Head>
111,
private Tuple<Tail...>
113 template <
unsigned I,
typename... Elements>
115 ->
decltype(
get_height<
sizeof...(Elements) - I - 1>(t));
124 using HeadElt =
TupleElt<
sizeof...(Tail), Head>;
137template <
unsigned I,
typename... Elements>
141 return get_height<
sizeof...(Elements) - I - 1>(t);
144template <
typename... Tp>
149template <
typename List>
153 static constexpr bool value =
false;
163template <
typename List,
typename NewElement>
166template <
typename... Elements,
typename NewElement>
173template <
typename List,
typename NewElement>
176template <
typename List>
179template <
typename Head,
typename... Tail>
183 using Type = std::tuple<Tail...>;
186template <
typename List>
189template <
typename List,
typename Element>
192template <
typename... Types,
typename Element>
196 using Type = std::tuple<Element, Types...>;
199template <
typename List,
typename NewElement>
202template <
typename... Types,
typename V>
204pushFront(std::tuple<Types...>
const& tuple, V
const& value)
206 return PushFront<std::tuple<Types...>, V>(value, tuple);
209template <
typename T, T... Values>
213template <
typename... Types>
216template <
typename FrontT,
typename... Types>
222template <
typename... Types>
225template <
typename BackT,
typename... Types>
233template <
typename List,
template <
typename T>
class MetaFun,
238template <
typename List,
template <
typename T>
class MetaFun>
240:
public PushFrontT<typename TransformT<PopFront<List>, MetaFun>::Type,
241 typename MetaFun<Front<List>>::Type>
245template <
typename List,
template <
typename T>
class MetaFun>
252template <
typename List,
template <
typename T>
class MetaFun>
255template <
typename... Elements,
template <
typename T>
class MetaFun>
265 template <
typename Func,
typename Head,
typename... Tail>
266 static inline auto forward(Func&& func, Head&& head, Tail&&... tail)
268 std::forward<Func>(func), std::forward<Head>(head),
269 std::get<N - 1>(std::forward<Head>(head)), std::forward<Tail>(tail)...))
272 std::forward<Func>(func), std::forward<Head>(head),
273 std::get<N - 1>(std::forward<Head>(head)), std::forward<Tail>(tail)...);
282 template <
typename Func,
typename Head,
typename... Tail>
283 static inline auto forward(Func&& func, Head&&, Tail&&... tail)
284 ->
decltype(std::forward<Func>(func)(std::forward<Tail>(tail)...))
286 return std::forward<Func>(func)(std::forward<Tail>(tail)...);
295 template <
typename Func,
typename Head>
296 static inline auto apply(Func&& func, Head&& head)
298 std::forward<Func>(func)(std::forward<Head>(head));
301 template <
typename Func,
typename Head,
typename... Tail>
302 static inline void apply(Func&& func, Head&& head, Tail&&... tail)
304 std::forward<Func>(func)(std::forward<Head>(head));
306 std::forward<Tail>(tail)...);
312template <
typename Func,
typename Tuple>
317 std::forward<Func>(func), std::forward<std::tuple>(_tuple));
322template <
typename Func,
typename Tuple, std::
size_t Head>
326 func(std::get<Head>(data));
331template <
typename Func,
typename Tuple, std::size_t Head, std::size_t... Tail>
335 func(std::get<Head>(data));
341template <typename Func, typename Tuple, std::size_t N = std::tuple_size<Tuple>::value,
342 typename Indices = std::make_index_sequence<N>>
352template <
typename Container, std::size_t... N>
356 return std::make_tuple(tasks[N]...);
361template <std::size_t N,
typename Container,
362 typename Indices = std::make_index_sequence<N>>
371template <
typename... Args>
374 static std::tuple<>
get(
const std::tuple<>&) {
return std::tuple<>{}; }
376 template <
typename... SubArgs>
377 static std::tuple<SubArgs...>
get(
const std::tuple<Args...>& t)
379 return std::tuple<SubArgs...>{ std::get<SubArgs>(t)... };
383template <
typename Head>
386 const std::tuple<Head>& data)
388 pred(std::get<0>(data));
391template <
typename Head,
typename... Tail>
394 const std::tuple<Head, Tail...>& data)
396 pred(std::get<0>(data));
397 auto subset =
tuple_subset<Head, Tail...>::template
get<Tail...>(data);
398 tuple_transform<Tail...>(pred, std::forward<decltype(subset)>(subset));
401template <
typename Head,
typename... Tail>
405 template <
typename TupleType>
408 func(std::get<0>(t));
414template <
typename Head>
418 template <
typename TupleType>
421 func(std::get<0>(t));
427template <
typename Func,
typename... Elements,
unsigned... Indices>
430 ->
decltype(func(std::get<Indices>(t)...))
432 return func(std::get<Indices>(t)...);
435template <
typename Func,
typename... Elements,
unsigned N =
sizeof...(Elements)>
437apply(Func func, std::tuple<Elements...>
const& t)
438 ->
decltype(
applyImpl(func, t, std::make_index_sequence<N>()))
440 return applyImpl(func, t, std::make_index_sequence<N>());
static constexpr bool value
std::tuple< Tail... > Type
std::tuple< Element, Types... > Type
const Head & head() const
const Tuple< Tail... > & tail() const
Tuple< Tail... > & tail()
typename PopFrontT< List >::Type PopFront
auto InvokeSequence(const Func &func, const Tuple &data)
auto apply(Func func, std::tuple< Elements... > const &t) -> decltype(applyImpl(func, t, std::make_index_sequence< N >()))
PushFront< std::tuple< Types... >, V > pushFront(std::tuple< Types... > const &tuple, V const &value)
auto ContainerToTuple_impl(const Container &tasks, std::index_sequence< N... >)
void tuple_transform(const std::function< void(const Head &)> &pred, const std::tuple< Head > &data)
void for_each_tuple_arg(Func &&func, Tuple &&_tuple)
typename PushBackT< List, NewElement >::Type PushBack
auto get(Tuple< Elements... > &t) -> decltype(get_height< sizeof...(Elements) - I - 1 >(t))
auto InvokeSequence_impl(const Func &func, const Tuple &data)
auto applyImpl(Func func, std::tuple< Elements... > const &t, Valuelist< unsigned, Indices... >) -> decltype(func(std::get< Indices >(t)...))
typename TransformT< List, MetaFun >::Type Transform
T & get_height(TupleElt< H, T > &te)
typename PushFrontT< List, NewElement >::Type PushFront
auto ContainerToTuple(const Container &tasks)
static constexpr Tp value
static void apply(Func &&func, Head &&head, Tail &&... tail)
static auto apply(Func &&func, Head &&head)
static auto forward(Func &&func, Head &&, Tail &&... tail) -> decltype(std::forward< Func >(func)(std::forward< Tail >(tail)...))
static auto forward(Func &&func, Head &&head, Tail &&... tail) -> decltype(ForwardTupleAsArgs< N - 1 >::forward(std::forward< Func >(func), std::forward< Head >(head), std::get< N - 1 >(std::forward< Head >(head)), std::forward< Tail >(tail)...))
static constexpr bool value
static std::tuple get(const std::tuple<> &)
static std::tuple< SubArgs... > get(const std::tuple< Args... > &t)