13 #ifndef TINYMPL_BIND_HPP
14 #define TINYMPL_BIND_HPP
16 #include <tinympl/variadic.hpp>
43 template<
template<
class ... T>
class F,class ... Args> struct
bind;
45 template<std::
size_t>
struct arg;
59 template<
class T>
struct is_placeholder : std::integral_constant<std::size_t, 0> {};
60 template<std::
size_t i>
struct is_placeholder< arg<i> > : std::integral_constant<std::size_t, i>
62 static_assert(i != 0,
"Placeholder arg<0> is undefined");
69 template<
template<
class ... T>
class F,class ... Args> struct
is_bind_expression<
bind<F,Args...> > : std::true_type {};
73 template<
template<
class ... T>
class F,class Head,class ... Tail> struct bind<F,Head,Tail...>
76 template<
class ... Args>
79 template<
class ... BoundArgs>
82 template<
class T,
class Enable =
void>
struct pick {
typedef T type;};
83 template<
class T>
struct pick<T, typename std::enable_if< (is_placeholder<T>::value > 0) >::type> {
typedef variadic::at_t<is_placeholder<T>::value-1, Args ... > type;};
84 template<
class T>
struct pick<T, typename std::enable_if< is_bind_expression<T>::type::value>::type> {
typedef typename T::template eval<Args...>::type type;};
86 typedef typename pick<Head>::type argument_t;
89 typedef typename bind<F,Tail...>::template call<Args...>::template eval<BoundArgs..., argument_t>::type type;
93 template<
template<
class ...>
class,
class ...>
friend struct bind;
96 template<
class ... Args>
99 using type =
typename call<Args...>::template eval<>::type;
102 template<
class ... Args>
103 using eval_t =
typename eval<Args...>::type;
106 template<
template<
class ... T>
class F> struct bind<F>
109 template<
class ... Args>
112 template<
class ... BoundArgs>
115 typedef typename F<BoundArgs...>::type type;
119 template<
template<
class ...>
class,
class ...>
friend struct bind;
122 template<
class ... Args>
125 using type =
typename call<Args...>::template eval<>::type;
128 template<
class ... Args>
129 using eval_t =
typename eval<Args...>::type;
134 #endif // MPL_BIND_HPP
Determine whether a type is a placeholder. is_placeholder::value is 0 if T is not a placeholder...
Definition: bind.hpp:59
Produce a template type by binding the given arguments on the passed template template.
Definition: bind.hpp:43
Determine whether a type is a bind expression.
Definition: bind.hpp:68