2 // Copyright 2000 John Maddock (john@johnmaddock.co.uk)
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED
10 #define BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED
12 #include <boost/config.hpp>
13 #include <boost/type_traits/is_function.hpp>
14 #include <boost/type_traits/add_pointer.hpp>
20 template<typename Function> struct function_traits_helper;
23 struct function_traits_helper<R (*)(void)>
25 BOOST_STATIC_CONSTANT(unsigned, arity = 0);
26 typedef R result_type;
29 template<typename R, typename T1>
30 struct function_traits_helper<R (*)(T1)>
32 BOOST_STATIC_CONSTANT(unsigned, arity = 1);
33 typedef R result_type;
35 typedef T1 argument_type;
38 template<typename R, typename T1, typename T2>
39 struct function_traits_helper<R (*)(T1, T2)>
41 BOOST_STATIC_CONSTANT(unsigned, arity = 2);
42 typedef R result_type;
45 typedef T1 first_argument_type;
46 typedef T2 second_argument_type;
49 template<typename R, typename T1, typename T2, typename T3>
50 struct function_traits_helper<R (*)(T1, T2, T3)>
52 BOOST_STATIC_CONSTANT(unsigned, arity = 3);
53 typedef R result_type;
59 template<typename R, typename T1, typename T2, typename T3, typename T4>
60 struct function_traits_helper<R (*)(T1, T2, T3, T4)>
62 BOOST_STATIC_CONSTANT(unsigned, arity = 4);
63 typedef R result_type;
70 template<typename R, typename T1, typename T2, typename T3, typename T4,
72 struct function_traits_helper<R (*)(T1, T2, T3, T4, T5)>
74 BOOST_STATIC_CONSTANT(unsigned, arity = 5);
75 typedef R result_type;
83 template<typename R, typename T1, typename T2, typename T3, typename T4,
84 typename T5, typename T6>
85 struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6)>
87 BOOST_STATIC_CONSTANT(unsigned, arity = 6);
88 typedef R result_type;
97 template<typename R, typename T1, typename T2, typename T3, typename T4,
98 typename T5, typename T6, typename T7>
99 struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7)>
101 BOOST_STATIC_CONSTANT(unsigned, arity = 7);
102 typedef R result_type;
103 typedef T1 arg1_type;
104 typedef T2 arg2_type;
105 typedef T3 arg3_type;
106 typedef T4 arg4_type;
107 typedef T5 arg5_type;
108 typedef T6 arg6_type;
109 typedef T7 arg7_type;
112 template<typename R, typename T1, typename T2, typename T3, typename T4,
113 typename T5, typename T6, typename T7, typename T8>
114 struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8)>
116 BOOST_STATIC_CONSTANT(unsigned, arity = 8);
117 typedef R result_type;
118 typedef T1 arg1_type;
119 typedef T2 arg2_type;
120 typedef T3 arg3_type;
121 typedef T4 arg4_type;
122 typedef T5 arg5_type;
123 typedef T6 arg6_type;
124 typedef T7 arg7_type;
125 typedef T8 arg8_type;
128 template<typename R, typename T1, typename T2, typename T3, typename T4,
129 typename T5, typename T6, typename T7, typename T8, typename T9>
130 struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
132 BOOST_STATIC_CONSTANT(unsigned, arity = 9);
133 typedef R result_type;
134 typedef T1 arg1_type;
135 typedef T2 arg2_type;
136 typedef T3 arg3_type;
137 typedef T4 arg4_type;
138 typedef T5 arg5_type;
139 typedef T6 arg6_type;
140 typedef T7 arg7_type;
141 typedef T8 arg8_type;
142 typedef T9 arg9_type;
145 template<typename R, typename T1, typename T2, typename T3, typename T4,
146 typename T5, typename T6, typename T7, typename T8, typename T9,
148 struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
150 BOOST_STATIC_CONSTANT(unsigned, arity = 10);
151 typedef R result_type;
152 typedef T1 arg1_type;
153 typedef T2 arg2_type;
154 typedef T3 arg3_type;
155 typedef T4 arg4_type;
156 typedef T5 arg5_type;
157 typedef T6 arg6_type;
158 typedef T7 arg7_type;
159 typedef T8 arg8_type;
160 typedef T9 arg9_type;
161 typedef T10 arg10_type;
164 } // end namespace detail
166 template<typename Function>
167 struct function_traits :
168 public boost::detail::function_traits_helper<typename boost::add_pointer<Function>::type>
174 #endif // BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED