13 #ifndef TINYMPL_LAMBDA_HPP
14 #define TINYMPL_LAMBDA_HPP
16 #include <tinympl/bind.hpp>
17 #include <type_traits>
27 template<
class T>
struct protect {
typedef T type;};
32 template<
class ... Ts>
35 template<
class T,
class Enable =
void>
struct pick {
typedef T type;};
36 template<
class T>
struct pick<T, typename std::enable_if< (is_placeholder<T>::type::value > 0)>::type> {
typedef variadic::at_t<is_placeholder<T>::value-1, Ts ... > type;};
37 template<
class T>
struct pick<T, typename std::enable_if< is_bind_expression<T>::type::value>::type> {
typedef typename T::template eval<Ts...>::type type;};
39 typedef typename pick<Expr>::type type;
42 template<
class ... Ts>
using eval_t =
typename eval<Ts...>::type;
45 template<
template<
class ...>
class F,
class ... Args>
struct lambda<F<Args...> >
47 template<
class ... Ts>
50 template<
class T>
using forward_t =
typename T::template eval<Ts...>::type;
52 typedef typename F< forward_t<lambda<Args> > ... >::type type;
55 template<
class ... Ts>
using eval_t =
typename eval<Ts...>::type;
58 template<
template<
class ...>
class F,
class ... Args>
struct lambda< protect<F<Args...> > >
60 template<
class ... Ts>
63 template<
class T>
using forward_t =
typename T::template eval<Ts...>::type;
65 typedef F< forward_t< lambda<protect<Args> > > ... > type;
68 template<
class ... Ts>
using eval_t =
typename eval<Ts...>::type;
71 template<
class Expr>
struct is_bind_expression<lambda<Expr> > : std::true_type {};
77 #endif // TINYMPL_LAMBDA_HPP