11#include <bond/core/config.h>
13#include <boost/static_assert.hpp>
15#include <initializer_list>
20namespace bond {
namespace detail {
namespace mpl
23template <
typename...>
struct
29template <
typename... T>
30using void_t =
typename make_void<T...>::type;
33template <
typename T>
struct
47template <
typename... T>
struct
52template <
typename List,
typename... T>
struct
55template <
typename List,
typename... T>
56using append_t =
typename append<List, T...>::type;
58template <
typename List,
typename... T>
struct
62template <
typename... T,
typename... U>
struct
64 : identity<
list<T..., U...> > {};
68template <
typename List,
template <
typename>
class C>
struct
71template <
typename List,
template <
typename>
class C>
74template <
template <
typename>
class C>
struct
76 : identity<list<> > {};
78template <
typename T,
typename... U,
template <
typename>
class C>
struct
83template <
typename F,
typename... T>
84inline void apply(F&& f,
const list<T...>&)
86 std::initializer_list<int>{ (f(identity<T>{}), 0)... };
90inline void apply(F&& ,
const list<>&)
93template <
typename List,
typename F>
94inline void apply(F&& f)
96 apply(std::forward<F>(f), List{});
100template <
typename F,
typename T>
101inline auto try_apply(F&& f,
const list<T>&)
102#ifdef BOND_NO_CXX14_RETURN_TYPE_DEDUCTION
103 ->
decltype(std::forward<F>(f)(identity<T>{}))
106 return std::forward<F>(f)(identity<T>{});
109template <
typename F,
typename T,
typename U,
typename... R>
110inline auto try_apply(F&& f,
const list<T, U, R...>&)
111#ifdef BOND_NO_CXX14_RETURN_TYPE_DEDUCTION
112 ->
decltype(f(identity<T>{}))
115 if (
auto&& result = f(identity<T>{}))
117 return std::move(result);
120 return try_apply(std::forward<F>(f), list<U, R...>{});
123template <
typename List,
typename F>
124inline auto try_apply(F&& f)
125#ifdef BOND_NO_CXX14_RETURN_TYPE_DEDUCTION
126 ->
decltype(try_apply(std::forward<F>(f), List{}))
129 BOOST_STATIC_ASSERT((!std::is_same<List, list<> >::value));
131 return try_apply(std::forward<F>(f), List{});
namespace bond
Definition: apply.h:17
Appends the given list of types or a single pack of list<> to the end.
Definition: mpl.h:60
Filters the given type list with the provided predicate.
Definition: mpl.h:68
Represents a type list.
Definition: mpl.h:48