Utopia  2
Framework for studying models of complex & adaptive systems.
metaprogramming.hh
Go to the documentation of this file.
1 
5 #ifndef UTOPIA_CORE_COMPILETIME_ALGOS_HH
6 #define UTOPIA_CORE_COMPILETIME_ALGOS_HH
7 #include "type_traits.hh"
8 
9 namespace Utopia {
10 // namespace for implementing tuple for each
11 namespace _Metaprogramming_helpers {
19 template<template<typename...> class Metafunc, typename Tuplelike, typename X>
20 struct apply_impl;
21 
31 template<template<typename...> class Metafunc,
32  typename Tuplelike,
33  std::size_t... idxs>
34 struct apply_impl<Metafunc, Tuplelike, std::index_sequence<idxs...>>
35 {
36  // application of metafunction
37  using type = typename Metafunc<
38  typename std::tuple_element_t<idxs, Tuplelike>...>::type;
39 };
40 
41 } // namespace _Metaprogramming_helpers
42 
43 namespace Utils {
44 
45 
54 template<template<typename...> class Metafunc, typename Tuplelike>
55 struct apply
56 {
57 
59  Metafunc,
60  std::decay_t<Tuplelike>,
61  std::make_index_sequence<std::tuple_size_v<std::decay_t<Tuplelike>>>>::type;
62 };
63 
72 template<template<typename...> class Metafunc, typename Tuplelike>
74 
75 
76 } // namespace Utils
77 } // namespace Utopia
78 #endif
typename apply< Metafunc, Tuplelike >::type apply_t
Alias for apply for applying a metafunction to a tuple.
Definition: metaprogramming.hh:73
Definition: agent.hh:11
Definition: parallel.hh:235
typename Metafunc< typename std::tuple_element_t< idxs, Tuplelike >... >::type type
Definition: metaprogramming.hh:38
Prototype for apply_impl.
Definition: metaprogramming.hh:20
Apply the metafunction 'Metafunc' to a tuplelike type 'Tuplelike'.
Definition: metaprogramming.hh:56
typename _Metaprogramming_helpers::apply_impl< Metafunc, std::decay_t< Tuplelike >, std::make_index_sequence< std::tuple_size_v< std::decay_t< Tuplelike > >> >::type type
Definition: metaprogramming.hh:61