10 #ifndef TRAITS_HPP_INCLUDED
11 #define TRAITS_HPP_INCLUDED
13 #include <type_traits>
17 namespace function_traits{
28 template<
class R,
class... Args>
33 template<
class T,
class R,
class... Args>
38 template<
class T,
class R,
class... Args>
41 using return_type = R;
43 static constexpr std::size_t arity =
sizeof...(Args);
45 template <std::
size_t N>
48 static_assert(N < arity,
"error: invalid parameter index.");
49 using type =
typename std::tuple_element<N,std::tuple<Args...>>::type;
62 template<
int pos,
typename T,
typename... Args>
66 template<
int pos,
typename T,
typename Arg>
70 static constexpr
bool value = std::is_same<Arg,typename Traits::type >::value;
73 template<
int pos,
typename T,
typename Head,
typename... Tail>
77 static constexpr
bool value = std::is_same<Head,typename Traits::type >::value &&
check_signature<pos+1,T,Tail...>::value;
86 template<
bool b1,
bool b2>
89 static constexpr
bool value =
false;
94 static constexpr
bool value =
true;
106 #define CREATE_MEMBER_DETECTOR(X) \
107 namespace function_traits{template<typename C,typename F> \
110 template<typename C, typename Ret, typename... Args> \
111 class has_##X<C,Ret(Args...)> { \
113 template<class U, class P = typename std::enable_if<function_traits::_implem::static_and< \
114 std::is_same< decltype( std::declval<U>().X( std::declval<Args>()... ) ), Ret >::value, \
115 function_traits::_implem::check_signature<0,decltype(&U::X),Args...>::value \
117 static std::true_type check(int); \
118 template <class,class P = void> \
119 static std::false_type check(...); \
121 static constexpr bool value = decltype(check<C>(0))::value; \
127 #define CREATE_STATIC_MEMBER_DETECTOR(X) \
128 namespace function_traits{template <class T> \
131 template<class U, class = typename std::enable_if<!std::is_member_pointer<decltype(&U::X)>::value>::type> \
132 static std::true_type check(int); \
134 static std::false_type check(...); \
136 static constexpr bool value = decltype(check<T>(0))::value; \
Definition: Traits.hpp:87
Definition: Traits.hpp:63
Definition: Traits.hpp:25