1
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).
6//
7// See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
9#ifndef BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED
10#define BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED
11
12#include <boost/config.hpp>
13#include <boost/type_traits/is_function.hpp>
14#include <boost/type_traits/add_pointer.hpp>
15
16namespace boost {
17
18namespace detail {
19
20template<typename Function> struct function_traits_helper;
21
22template<typename R>
23struct function_traits_helper<R (*)(void)>
24{
25 BOOST_STATIC_CONSTANT(unsigned, arity = 0);
26 typedef R result_type;
27};
28
29template<typename R, typename T1>
30struct function_traits_helper<R (*)(T1)>
31{
32 BOOST_STATIC_CONSTANT(unsigned, arity = 1);
33 typedef R result_type;
34 typedef T1 arg1_type;
35 typedef T1 argument_type;
36};
37
38template<typename R, typename T1, typename T2>
39struct function_traits_helper<R (*)(T1, T2)>
40{
41 BOOST_STATIC_CONSTANT(unsigned, arity = 2);
42 typedef R result_type;
43 typedef T1 arg1_type;
44 typedef T2 arg2_type;
45 typedef T1 first_argument_type;
46 typedef T2 second_argument_type;
47};
48
49template<typename R, typename T1, typename T2, typename T3>
50struct function_traits_helper<R (*)(T1, T2, T3)>
51{
52 BOOST_STATIC_CONSTANT(unsigned, arity = 3);
53 typedef R result_type;
54 typedef T1 arg1_type;
55 typedef T2 arg2_type;
56 typedef T3 arg3_type;
57};
58
59template<typename R, typename T1, typename T2, typename T3, typename T4>
60struct function_traits_helper<R (*)(T1, T2, T3, T4)>
61{
62 BOOST_STATIC_CONSTANT(unsigned, arity = 4);
63 typedef R result_type;
64 typedef T1 arg1_type;
65 typedef T2 arg2_type;
66 typedef T3 arg3_type;
67 typedef T4 arg4_type;
68};
69
70template<typename R, typename T1, typename T2, typename T3, typename T4,
71 typename T5>
72struct function_traits_helper<R (*)(T1, T2, T3, T4, T5)>
73{
74 BOOST_STATIC_CONSTANT(unsigned, arity = 5);
75 typedef R result_type;
76 typedef T1 arg1_type;
77 typedef T2 arg2_type;
78 typedef T3 arg3_type;
79 typedef T4 arg4_type;
80 typedef T5 arg5_type;
81};
82
83template<typename R, typename T1, typename T2, typename T3, typename T4,
84 typename T5, typename T6>
85struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6)>
86{
87 BOOST_STATIC_CONSTANT(unsigned, arity = 6);
88 typedef R result_type;
89 typedef T1 arg1_type;
90 typedef T2 arg2_type;
91 typedef T3 arg3_type;
92 typedef T4 arg4_type;
93 typedef T5 arg5_type;
94 typedef T6 arg6_type;
95};
96
97template<typename R, typename T1, typename T2, typename T3, typename T4,
98 typename T5, typename T6, typename T7>
99struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7)>
100{
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;
110};
111
112template<typename R, typename T1, typename T2, typename T3, typename T4,
113 typename T5, typename T6, typename T7, typename T8>
114struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8)>
115{
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;
126};
127
128template<typename R, typename T1, typename T2, typename T3, typename T4,
129 typename T5, typename T6, typename T7, typename T8, typename T9>
130struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
131{
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;
143};
144
145template<typename R, typename T1, typename T2, typename T3, typename T4,
146 typename T5, typename T6, typename T7, typename T8, typename T9,
147 typename T10>
148struct function_traits_helper<R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
149{
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;
162};
163
164} // end namespace detail
165
166template<typename Function>
167struct function_traits :
168 public boost::detail::function_traits_helper<typename boost::add_pointer<Function>::type>
169{
170};
171
172}
173
174#endif // BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED
175