Chris@16
|
1 // Boost result_of library
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright Douglas Gregor 2004. Use, modification and
|
Chris@16
|
4 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7
|
Chris@16
|
8 // Copyright Daniel Walker, Eric Niebler, Michel Morin 2008-2012.
|
Chris@16
|
9 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
10 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or
|
Chris@16
|
11 // copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
12
|
Chris@16
|
13 // For more information, see http://www.boost.org/libs/utility
|
Chris@16
|
14 #if !defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
15 # error Boost result_of - do not include this file!
|
Chris@16
|
16 #endif
|
Chris@16
|
17
|
Chris@16
|
18 // CWPro8 requires an argument in a function type specialization
|
Chris@16
|
19 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0
|
Chris@16
|
20 # define BOOST_RESULT_OF_ARGS void
|
Chris@16
|
21 #else
|
Chris@16
|
22 # define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)
|
Chris@16
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
Chris@16
|
26 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
27 struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
|
Chris@16
|
28 : mpl::if_<
|
Chris@16
|
29 mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
|
Chris@16
|
30 , boost::detail::tr1_result_of_impl<
|
Chris@16
|
31 typename remove_cv<F>::type,
|
Chris@16
|
32 typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
|
Chris@16
|
33 (boost::detail::has_result_type<F>::value)>
|
Chris@16
|
34 , boost::detail::tr1_result_of_impl<
|
Chris@16
|
35 F,
|
Chris@16
|
36 F(BOOST_RESULT_OF_ARGS),
|
Chris@16
|
37 (boost::detail::has_result_type<F>::value)> >::type { };
|
Chris@16
|
38 #endif
|
Chris@16
|
39
|
Chris@16
|
40 #ifdef BOOST_RESULT_OF_USE_DECLTYPE
|
Chris@16
|
41 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
42 struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
Chris@16
|
43 : detail::cpp0x_result_of<F(BOOST_RESULT_OF_ARGS)> { };
|
Chris@16
|
44 #endif // BOOST_RESULT_OF_USE_DECLTYPE
|
Chris@16
|
45
|
Chris@16
|
46 #ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
Chris@16
|
47 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
48 struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
Chris@16
|
49 : mpl::if_<mpl::or_<detail::has_result_type<F>, detail::has_result<F> >,
|
Chris@16
|
50 tr1_result_of<F(BOOST_RESULT_OF_ARGS)>,
|
Chris@16
|
51 detail::cpp0x_result_of<F(BOOST_RESULT_OF_ARGS)> >::type { };
|
Chris@16
|
52 #endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
Chris@16
|
53
|
Chris@16
|
54 #if defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
|
Chris@16
|
55
|
Chris@16
|
56 namespace detail {
|
Chris@16
|
57
|
Chris@16
|
58 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
59 struct cpp0x_result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
Chris@16
|
60 : mpl::if_<
|
Chris@16
|
61 is_member_function_pointer<F>
|
Chris@16
|
62 , detail::tr1_result_of_impl<
|
Chris@16
|
63 typename remove_cv<F>::type,
|
Chris@16
|
64 typename remove_cv<F>::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
|
Chris@16
|
65 >
|
Chris@16
|
66 , detail::cpp0x_result_of_impl<
|
Chris@16
|
67 F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))
|
Chris@16
|
68 >
|
Chris@16
|
69 >::type
|
Chris@16
|
70 {};
|
Chris@16
|
71
|
Chris@16
|
72 #ifdef BOOST_NO_SFINAE_EXPR
|
Chris@16
|
73
|
Chris@16
|
74 template<typename F>
|
Chris@16
|
75 struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION());
|
Chris@16
|
76
|
Chris@16
|
77 template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
|
Chris@16
|
78 struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<R(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))> {
|
Chris@16
|
79 R operator()(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const;
|
Chris@16
|
80 typedef result_of_private_type const &(*pfn_t)(...);
|
Chris@16
|
81 operator pfn_t() const volatile;
|
Chris@16
|
82 };
|
Chris@16
|
83
|
Chris@16
|
84 template<typename F>
|
Chris@16
|
85 struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION());
|
Chris@16
|
86
|
Chris@16
|
87 template<typename F>
|
Chris@16
|
88 struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F *>
|
Chris@16
|
89 : BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
|
Chris@16
|
90 {};
|
Chris@16
|
91
|
Chris@16
|
92 template<typename F>
|
Chris@16
|
93 struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F &>
|
Chris@16
|
94 : BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
|
Chris@16
|
95 {};
|
Chris@16
|
96
|
Chris@16
|
97 template<typename F>
|
Chris@16
|
98 struct BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())
|
Chris@16
|
99 : mpl::eval_if<
|
Chris@16
|
100 is_class<typename remove_reference<F>::type>,
|
Chris@16
|
101 result_of_wrap_callable_class<F>,
|
Chris@16
|
102 mpl::identity<BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<typename remove_cv<F>::type> >
|
Chris@16
|
103 >
|
Chris@16
|
104 {};
|
Chris@16
|
105
|
Chris@16
|
106 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
|
Chris@16
|
107 struct BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION()) {
|
Chris@16
|
108 typedef typename BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())<F>::type wrapper_t;
|
Chris@16
|
109 static const bool value = (
|
Chris@16
|
110 sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type(
|
Chris@16
|
111 (boost::declval<wrapper_t>()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)), result_of_weird_type())
|
Chris@16
|
112 ))
|
Chris@16
|
113 );
|
Chris@16
|
114 typedef mpl::bool_<value> type;
|
Chris@16
|
115 };
|
Chris@16
|
116
|
Chris@16
|
117 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
118 struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), true>
|
Chris@16
|
119 : lazy_enable_if<
|
Chris@16
|
120 BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION())<F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), T)>
|
Chris@16
|
121 , cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false>
|
Chris@16
|
122 >
|
Chris@16
|
123 {};
|
Chris@16
|
124
|
Chris@16
|
125 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
126 struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false>
|
Chris@16
|
127 {
|
Chris@16
|
128 typedef decltype(
|
Chris@16
|
129 boost::declval<F>()(
|
Chris@16
|
130 BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
|
Chris@16
|
131 )
|
Chris@16
|
132 ) type;
|
Chris@16
|
133 };
|
Chris@16
|
134
|
Chris@16
|
135 #else // BOOST_NO_SFINAE_EXPR
|
Chris@16
|
136
|
Chris@16
|
137 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
138 struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
|
Chris@16
|
139 typename result_of_always_void<decltype(
|
Chris@16
|
140 boost::declval<F>()(
|
Chris@16
|
141 BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
|
Chris@16
|
142 )
|
Chris@16
|
143 )>::type> {
|
Chris@16
|
144 typedef decltype(
|
Chris@16
|
145 boost::declval<F>()(
|
Chris@16
|
146 BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
|
Chris@16
|
147 )
|
Chris@16
|
148 ) type;
|
Chris@16
|
149 };
|
Chris@16
|
150
|
Chris@16
|
151 #endif // BOOST_NO_SFINAE_EXPR
|
Chris@16
|
152
|
Chris@16
|
153 } // namespace detail
|
Chris@16
|
154
|
Chris@16
|
155 #else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
|
Chris@16
|
156
|
Chris@16
|
157 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
Chris@16
|
158 template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
159 struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
Chris@16
|
160 : tr1_result_of<F(BOOST_RESULT_OF_ARGS)> { };
|
Chris@16
|
161 #endif
|
Chris@16
|
162
|
Chris@16
|
163 #endif // defined(BOOST_RESULT_OF_USE_DECLTYPE)
|
Chris@16
|
164
|
Chris@16
|
165 #undef BOOST_RESULT_OF_ARGS
|
Chris@16
|
166
|
Chris@16
|
167 #if BOOST_PP_ITERATION() >= 1
|
Chris@16
|
168
|
Chris@16
|
169 namespace detail {
|
Chris@16
|
170
|
Chris@16
|
171 template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
172 struct tr1_result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
Chris@16
|
173 {
|
Chris@16
|
174 typedef R type;
|
Chris@16
|
175 };
|
Chris@16
|
176
|
Chris@16
|
177 template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
178 struct tr1_result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
Chris@16
|
179 {
|
Chris@16
|
180 typedef R type;
|
Chris@16
|
181 };
|
Chris@16
|
182
|
Chris@16
|
183 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
Chris@16
|
184 template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
185 struct tr1_result_of_impl<R (T0::*)
|
Chris@16
|
186 (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
|
Chris@16
|
187 FArgs, false>
|
Chris@16
|
188 {
|
Chris@16
|
189 typedef R type;
|
Chris@16
|
190 };
|
Chris@16
|
191
|
Chris@16
|
192 template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
193 struct tr1_result_of_impl<R (T0::*)
|
Chris@16
|
194 (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
Chris@16
|
195 const,
|
Chris@16
|
196 FArgs, false>
|
Chris@16
|
197 {
|
Chris@16
|
198 typedef R type;
|
Chris@16
|
199 };
|
Chris@16
|
200
|
Chris@16
|
201 template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
202 struct tr1_result_of_impl<R (T0::*)
|
Chris@16
|
203 (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
Chris@16
|
204 volatile,
|
Chris@16
|
205 FArgs, false>
|
Chris@16
|
206 {
|
Chris@16
|
207 typedef R type;
|
Chris@16
|
208 };
|
Chris@16
|
209
|
Chris@16
|
210 template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
Chris@16
|
211 struct tr1_result_of_impl<R (T0::*)
|
Chris@16
|
212 (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
Chris@16
|
213 const volatile,
|
Chris@16
|
214 FArgs, false>
|
Chris@16
|
215 {
|
Chris@16
|
216 typedef R type;
|
Chris@16
|
217 };
|
Chris@16
|
218 #endif
|
Chris@16
|
219
|
Chris@16
|
220 }
|
Chris@16
|
221 #endif
|