forked from boostorg/type_traits
function_traits.hpp
[SVN r14670]
This commit is contained in:
@ -148,6 +148,158 @@ public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = m_type::value);
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
namespace detail {
|
||||
|
||||
template<typename Function> struct function_traits_helper;
|
||||
|
||||
template<typename R>
|
||||
struct function_traits_helper<R (*)(void)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 0);
|
||||
typedef R result_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1>
|
||||
struct function_traits_helper<R (*)(T1)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 1);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2>
|
||||
struct function_traits_helper<R (*)(T1, T2)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 2);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 3);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename T4>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3, T4)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 4);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
typedef T4 arg4_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3, T4, T5)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 5);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
typedef T4 arg4_type;
|
||||
typedef T5 arg5_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 6);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
typedef T4 arg4_type;
|
||||
typedef T5 arg5_type;
|
||||
typedef T6 arg6_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 7);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
typedef T4 arg4_type;
|
||||
typedef T5 arg5_type;
|
||||
typedef T6 arg6_type;
|
||||
typedef T7 arg7_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 8);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
typedef T4 arg4_type;
|
||||
typedef T5 arg5_type;
|
||||
typedef T6 arg6_type;
|
||||
typedef T7 arg7_type;
|
||||
typedef T8 arg8_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8, typename T9>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 9);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
typedef T4 arg4_type;
|
||||
typedef T5 arg5_type;
|
||||
typedef T6 arg6_type;
|
||||
typedef T7 arg7_type;
|
||||
typedef T8 arg8_type;
|
||||
typedef T9 arg9_type;
|
||||
};
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8, typename T9,
|
||||
typename T10>
|
||||
struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, arity = 10);
|
||||
typedef R result_type;
|
||||
typedef T1 arg1_type;
|
||||
typedef T2 arg2_type;
|
||||
typedef T3 arg3_type;
|
||||
typedef T4 arg4_type;
|
||||
typedef T5 arg5_type;
|
||||
typedef T6 arg6_type;
|
||||
typedef T7 arg7_type;
|
||||
typedef T8 arg8_type;
|
||||
typedef T9 arg9_type;
|
||||
typedef T10 arg10_type;
|
||||
};
|
||||
} // end namespace detail
|
||||
|
||||
template<typename Function>
|
||||
struct function_traits :
|
||||
public detail::function_traits_helper<typename add_pointer<Function>::type>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
} // boost
|
||||
|
||||
#endif // BOOST_FUNCTION_TYPE_TRAITS_HPP
|
||||
|
Reference in New Issue
Block a user