Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2007-2008 Tobias Schwinger
|
Chris@16
|
3
|
Chris@16
|
4 Use modification and distribution are subject to the Boost Software
|
Chris@16
|
5 License, Version 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
|
Chris@16
|
9 #ifndef BOOST_FUNCTIONAL_FORWARD_ADAPTER_HPP_INCLUDED
|
Chris@16
|
10 # ifndef BOOST_PP_IS_ITERATING
|
Chris@16
|
11
|
Chris@16
|
12 # include <boost/config.hpp>
|
Chris@16
|
13 # include <boost/detail/workaround.hpp>
|
Chris@16
|
14
|
Chris@16
|
15 # include <boost/preprocessor/iteration/iterate.hpp>
|
Chris@16
|
16 # include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
17 # include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
Chris@16
|
18 # include <boost/preprocessor/facilities/intercept.hpp>
|
Chris@16
|
19 # include <boost/preprocessor/arithmetic/dec.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 # include <boost/utility/result_of.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 # ifndef BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY
|
Chris@16
|
24 # define BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY 6
|
Chris@16
|
25 # elif BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY < 3
|
Chris@16
|
26 # undef BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY
|
Chris@16
|
27 # define BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY 3
|
Chris@16
|
28 # endif
|
Chris@16
|
29
|
Chris@16
|
30
|
Chris@16
|
31 namespace boost
|
Chris@16
|
32 {
|
Chris@16
|
33 template< typename Function, int Arity_Or_MinArity = -1, int MaxArity = -1 >
|
Chris@16
|
34 class forward_adapter;
|
Chris@16
|
35
|
Chris@16
|
36 //----- ---- --- -- - - - -
|
Chris@16
|
37
|
Chris@16
|
38 namespace detail
|
Chris@16
|
39 {
|
Chris@16
|
40 template< class MostDerived, typename Function, typename FunctionConst,
|
Chris@16
|
41 int Arity, int MinArity >
|
Chris@16
|
42 struct forward_adapter_impl;
|
Chris@16
|
43
|
Chris@16
|
44 struct forward_adapter_result
|
Chris@16
|
45 {
|
Chris@16
|
46 template< typename Sig > struct apply;
|
Chris@16
|
47
|
Chris@16
|
48 // Utility metafunction for qualification adjustment on arguments
|
Chris@16
|
49 template< typename T > struct q { typedef T const t; };
|
Chris@16
|
50 template< typename T > struct q<T const> { typedef T const t; };
|
Chris@16
|
51 template< typename T > struct q<T &> { typedef T t; };
|
Chris@16
|
52
|
Chris@16
|
53 // Utility metafunction to choose target function qualification
|
Chris@16
|
54 template< typename T > struct c
|
Chris@16
|
55 { typedef typename T::target_function_t t; };
|
Chris@16
|
56 template< typename T > struct c<T& >
|
Chris@16
|
57 { typedef typename T::target_function_t t; };
|
Chris@16
|
58 template< typename T > struct c<T const >
|
Chris@16
|
59 { typedef typename T::target_function_const_t t; };
|
Chris@16
|
60 template< typename T > struct c<T const&>
|
Chris@16
|
61 { typedef typename T::target_function_const_t t; };
|
Chris@16
|
62 };
|
Chris@16
|
63 }
|
Chris@16
|
64
|
Chris@16
|
65 # define BOOST_TMP_MACRO(f,fn,fc) \
|
Chris@16
|
66 boost::detail::forward_adapter_impl< \
|
Chris@16
|
67 forward_adapter<f,Arity_Or_MinArity,MaxArity>, fn, fc, \
|
Chris@16
|
68 (MaxArity!=-1? MaxArity :Arity_Or_MinArity!=-1? Arity_Or_MinArity \
|
Chris@16
|
69 :BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY), \
|
Chris@16
|
70 (Arity_Or_MinArity!=-1? Arity_Or_MinArity : 0) >
|
Chris@16
|
71
|
Chris@16
|
72 template< typename Function, int Arity_Or_MinArity, int MaxArity >
|
Chris@16
|
73 class forward_adapter
|
Chris@16
|
74 : public BOOST_TMP_MACRO(Function,Function,Function const)
|
Chris@16
|
75 , private Function
|
Chris@16
|
76 {
|
Chris@16
|
77 public:
|
Chris@16
|
78 forward_adapter(Function const& f = Function())
|
Chris@16
|
79 : Function(f)
|
Chris@16
|
80 { }
|
Chris@16
|
81
|
Chris@16
|
82 typedef Function target_function_t;
|
Chris@16
|
83 typedef Function const target_function_const_t;
|
Chris@16
|
84
|
Chris@16
|
85 Function & target_function() { return *this; }
|
Chris@16
|
86 Function const & target_function() const { return *this; }
|
Chris@16
|
87
|
Chris@16
|
88 template< typename Sig > struct result
|
Chris@16
|
89 : detail::forward_adapter_result::template apply<Sig>
|
Chris@16
|
90 { };
|
Chris@16
|
91
|
Chris@16
|
92 using BOOST_TMP_MACRO(Function,Function, Function const)::operator();
|
Chris@16
|
93 };
|
Chris@16
|
94 template< typename Function, int Arity_Or_MinArity, int MaxArity >
|
Chris@16
|
95 class forward_adapter< Function const, Arity_Or_MinArity, MaxArity >
|
Chris@16
|
96 : public BOOST_TMP_MACRO(Function const, Function const, Function const)
|
Chris@16
|
97 , private Function
|
Chris@16
|
98 {
|
Chris@16
|
99 public:
|
Chris@16
|
100 forward_adapter(Function const& f = Function())
|
Chris@16
|
101 : Function(f)
|
Chris@16
|
102 { }
|
Chris@16
|
103
|
Chris@16
|
104 typedef Function const target_function_t;
|
Chris@16
|
105 typedef Function const target_function_const_t;
|
Chris@16
|
106
|
Chris@16
|
107 Function const & target_function() const { return *this; }
|
Chris@16
|
108
|
Chris@16
|
109 template< typename Sig > struct result
|
Chris@16
|
110 : detail::forward_adapter_result::template apply<Sig>
|
Chris@16
|
111 { };
|
Chris@16
|
112
|
Chris@16
|
113 using BOOST_TMP_MACRO(Function const,Function const, Function const)
|
Chris@16
|
114 ::operator();
|
Chris@16
|
115 };
|
Chris@16
|
116 template< typename Function, int Arity_Or_MinArity, int MaxArity >
|
Chris@16
|
117 class forward_adapter< Function &, Arity_Or_MinArity, MaxArity >
|
Chris@16
|
118 : public BOOST_TMP_MACRO(Function&, Function, Function)
|
Chris@16
|
119 {
|
Chris@16
|
120 Function& ref_function;
|
Chris@16
|
121 public:
|
Chris@16
|
122 forward_adapter(Function& f)
|
Chris@16
|
123 : ref_function(f)
|
Chris@16
|
124 { }
|
Chris@16
|
125
|
Chris@16
|
126 typedef Function target_function_t;
|
Chris@16
|
127 typedef Function target_function_const_t;
|
Chris@16
|
128
|
Chris@16
|
129 Function & target_function() const { return this->ref_function; }
|
Chris@16
|
130
|
Chris@16
|
131 template< typename Sig > struct result
|
Chris@16
|
132 : detail::forward_adapter_result::template apply<Sig>
|
Chris@16
|
133 { };
|
Chris@16
|
134
|
Chris@16
|
135 using BOOST_TMP_MACRO(Function&, Function, Function)::operator();
|
Chris@16
|
136 };
|
Chris@16
|
137
|
Chris@16
|
138 #undef BOOST_TMP_MACRO
|
Chris@16
|
139
|
Chris@16
|
140 namespace detail
|
Chris@16
|
141 {
|
Chris@16
|
142 template< class Self >
|
Chris@16
|
143 struct forward_adapter_result::apply< Self() >
|
Chris@16
|
144 : boost::result_of< BOOST_DEDUCED_TYPENAME c<Self>::t() >
|
Chris@16
|
145 { };
|
Chris@16
|
146
|
Chris@16
|
147 template< class MD, class F, class FC >
|
Chris@16
|
148 struct forward_adapter_impl<MD,F,FC,0,0>
|
Chris@16
|
149 {
|
Chris@16
|
150 inline typename boost::result_of< FC() >::type
|
Chris@16
|
151 operator()() const
|
Chris@16
|
152 {
|
Chris@16
|
153 return static_cast<MD const*>(this)->target_function()();
|
Chris@16
|
154 }
|
Chris@16
|
155
|
Chris@16
|
156 inline typename boost::result_of< F() >::type
|
Chris@16
|
157 operator()()
|
Chris@16
|
158 {
|
Chris@16
|
159 return static_cast<MD*>(this)->target_function()();
|
Chris@16
|
160 }
|
Chris@16
|
161
|
Chris@16
|
162 // closing brace gets generated by preprocessing code, below
|
Chris@16
|
163
|
Chris@16
|
164 # define BOOST_TMP_MACRO(tpl_params,arg_types,params,args) \
|
Chris@16
|
165 template< tpl_params > \
|
Chris@16
|
166 inline typename boost::result_of< FC(arg_types) >::type \
|
Chris@16
|
167 operator()(params) const \
|
Chris@16
|
168 { \
|
Chris@16
|
169 return static_cast<MD const*>(this)->target_function()(args); \
|
Chris@16
|
170 } \
|
Chris@16
|
171 template< tpl_params > \
|
Chris@16
|
172 inline typename boost::result_of< F(arg_types)>::type \
|
Chris@16
|
173 operator()(params) \
|
Chris@16
|
174 { \
|
Chris@16
|
175 return static_cast<MD*>(this)->target_function()(args); \
|
Chris@16
|
176 }
|
Chris@16
|
177
|
Chris@16
|
178 # // This is the total number of iterations we need
|
Chris@16
|
179 # define count ((1 << BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY+1)-2)
|
Chris@16
|
180
|
Chris@16
|
181 # // Chain file iteration to virtually one loop
|
Chris@16
|
182 # if BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY <= 7
|
Chris@16
|
183 # define limit1 count
|
Chris@16
|
184 # define limit2 0
|
Chris@16
|
185 # define limit3 0
|
Chris@16
|
186 # else
|
Chris@16
|
187 # if BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY <= 15
|
Chris@16
|
188 # define limit1 (count >> 8)
|
Chris@16
|
189 # define limit2 255
|
Chris@16
|
190 # define limit3 0
|
Chris@16
|
191 # else
|
Chris@16
|
192 # define limit1 (count >> 16)
|
Chris@16
|
193 # define limit2 255
|
Chris@16
|
194 # define limit3 255
|
Chris@16
|
195 # endif
|
Chris@16
|
196 # endif
|
Chris@16
|
197
|
Chris@16
|
198 # define N 0
|
Chris@16
|
199
|
Chris@16
|
200 # define BOOST_PP_FILENAME_1 <boost/functional/forward_adapter.hpp>
|
Chris@16
|
201 # define BOOST_PP_ITERATION_LIMITS (0,limit1)
|
Chris@16
|
202 # include BOOST_PP_ITERATE()
|
Chris@16
|
203
|
Chris@16
|
204 # undef N
|
Chris@16
|
205 # undef limit3
|
Chris@16
|
206 # undef limit2
|
Chris@16
|
207 # undef limit1
|
Chris@16
|
208 # undef count
|
Chris@16
|
209 # undef BOOST_TMP_MACRO
|
Chris@16
|
210
|
Chris@16
|
211 };
|
Chris@16
|
212
|
Chris@16
|
213 } // namespace detail
|
Chris@16
|
214
|
Chris@16
|
215 template<class F, int A0, int A1>
|
Chris@16
|
216 struct result_of<boost::forward_adapter<F,A0,A1> const ()>
|
Chris@16
|
217 : boost::detail::forward_adapter_result::template apply<
|
Chris@16
|
218 boost::forward_adapter<F,A0,A1> const () >
|
Chris@16
|
219 { };
|
Chris@16
|
220 template<class F, int A0, int A1>
|
Chris@16
|
221 struct result_of<boost::forward_adapter<F,A0,A1>()>
|
Chris@16
|
222 : boost::detail::forward_adapter_result::template apply<
|
Chris@16
|
223 boost::forward_adapter<F,A0,A1>() >
|
Chris@16
|
224 { };
|
Chris@16
|
225 template<class F, int A0, int A1>
|
Chris@16
|
226 struct result_of<boost::forward_adapter<F,A0,A1> const& ()>
|
Chris@16
|
227 : boost::detail::forward_adapter_result::template apply<
|
Chris@16
|
228 boost::forward_adapter<F,A0,A1> const () >
|
Chris@16
|
229 { };
|
Chris@16
|
230 template<class F, int A0, int A1>
|
Chris@16
|
231 struct result_of<boost::forward_adapter<F,A0,A1>& ()>
|
Chris@16
|
232 : boost::detail::forward_adapter_result::template apply<
|
Chris@16
|
233 boost::forward_adapter<F,A0,A1>() >
|
Chris@16
|
234 { };
|
Chris@16
|
235 }
|
Chris@16
|
236
|
Chris@16
|
237 # define BOOST_FUNCTIONAL_FORWARD_ADAPTER_HPP_INCLUDED
|
Chris@16
|
238
|
Chris@16
|
239 # elif BOOST_PP_ITERATION_DEPTH() == 1 && limit2
|
Chris@16
|
240 # define BOOST_PP_FILENAME_2 <boost/functional/forward_adapter.hpp>
|
Chris@16
|
241 # define BOOST_PP_ITERATION_LIMITS (0,limit2)
|
Chris@16
|
242 # include BOOST_PP_ITERATE()
|
Chris@16
|
243 # elif BOOST_PP_ITERATION_DEPTH() == 2 && limit3
|
Chris@16
|
244 # define BOOST_PP_FILENAME_3 <boost/functional/forward_adapter.hpp>
|
Chris@16
|
245 # define BOOST_PP_ITERATION_LIMITS (0,limit3)
|
Chris@16
|
246 # include BOOST_PP_ITERATE()
|
Chris@16
|
247
|
Chris@16
|
248 # else
|
Chris@16
|
249
|
Chris@16
|
250 # // I is the loop counter
|
Chris@16
|
251 # if limit2 && limit3
|
Chris@16
|
252 # define I (BOOST_PP_ITERATION_1 << 16 | BOOST_PP_ITERATION_2 << 8 | \
|
Chris@16
|
253 BOOST_PP_ITERATION_3)
|
Chris@16
|
254 # elif limit2
|
Chris@16
|
255 # define I (BOOST_PP_ITERATION_1 << 8 | BOOST_PP_ITERATION_2)
|
Chris@16
|
256 # else
|
Chris@16
|
257 # define I BOOST_PP_ITERATION_1
|
Chris@16
|
258 # endif
|
Chris@16
|
259
|
Chris@16
|
260 # if I < count
|
Chris@16
|
261
|
Chris@16
|
262 # // Done for this arity? Increment N
|
Chris@16
|
263 # if (I+2 >> N+1)
|
Chris@16
|
264 # if N == 0
|
Chris@16
|
265 # undef N
|
Chris@16
|
266 # define N 1
|
Chris@16
|
267 # elif N == 1
|
Chris@16
|
268 # undef N
|
Chris@16
|
269 # define N 2
|
Chris@16
|
270 # elif N == 2
|
Chris@16
|
271 # undef N
|
Chris@16
|
272 # define N 3
|
Chris@16
|
273 # elif N == 3
|
Chris@16
|
274 # undef N
|
Chris@16
|
275 # define N 4
|
Chris@16
|
276 # elif N == 4
|
Chris@16
|
277 # undef N
|
Chris@16
|
278 # define N 5
|
Chris@16
|
279 # elif N == 5
|
Chris@16
|
280 # undef N
|
Chris@16
|
281 # define N 6
|
Chris@16
|
282 # elif N == 6
|
Chris@16
|
283 # undef N
|
Chris@16
|
284 # define N 7
|
Chris@16
|
285 # elif N == 7
|
Chris@16
|
286 # undef N
|
Chris@16
|
287 # define N 8
|
Chris@16
|
288 # elif N == 8
|
Chris@16
|
289 # undef N
|
Chris@16
|
290 # define N 9
|
Chris@16
|
291 # elif N == 9
|
Chris@16
|
292 # undef N
|
Chris@16
|
293 # define N 10
|
Chris@16
|
294 # elif N == 10
|
Chris@16
|
295 # undef N
|
Chris@16
|
296 # define N 11
|
Chris@16
|
297 # elif N == 11
|
Chris@16
|
298 # undef N
|
Chris@16
|
299 # define N 12
|
Chris@16
|
300 # elif N == 12
|
Chris@16
|
301 # undef N
|
Chris@16
|
302 # define N 13
|
Chris@16
|
303 # elif N == 13
|
Chris@16
|
304 # undef N
|
Chris@16
|
305 # define N 14
|
Chris@16
|
306 # elif N == 14
|
Chris@16
|
307 # undef N
|
Chris@16
|
308 # define N 15
|
Chris@16
|
309 # elif N == 15
|
Chris@16
|
310 # undef N
|
Chris@16
|
311 # define N 16
|
Chris@16
|
312 # endif
|
Chris@16
|
313
|
Chris@16
|
314 };
|
Chris@16
|
315
|
Chris@16
|
316 template< class Self, BOOST_PP_ENUM_PARAMS(N,typename T) >
|
Chris@16
|
317 struct forward_adapter_result::apply< Self(BOOST_PP_ENUM_PARAMS(N,T)) >
|
Chris@16
|
318 : boost::result_of<
|
Chris@16
|
319 BOOST_DEDUCED_TYPENAME c<Self>::t(BOOST_PP_ENUM_BINARY_PARAMS(N,
|
Chris@16
|
320 typename q<T,>::t& BOOST_PP_INTERCEPT)) >
|
Chris@16
|
321 { };
|
Chris@16
|
322
|
Chris@16
|
323 template< class MD, class F, class FC >
|
Chris@16
|
324 struct forward_adapter_impl<MD,F,FC,BOOST_PP_DEC(N),N>
|
Chris@16
|
325 {
|
Chris@16
|
326 template< BOOST_PP_ENUM_PARAMS(N,typename T) >
|
Chris@16
|
327 inline typename boost::result_of< F(
|
Chris@16
|
328 BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)) >::type
|
Chris@16
|
329 operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT));
|
Chris@16
|
330 };
|
Chris@16
|
331
|
Chris@16
|
332 template< class MD, class F, class FC, int MinArity >
|
Chris@16
|
333 struct forward_adapter_impl<MD,F,FC,N,MinArity>
|
Chris@16
|
334 : forward_adapter_impl<MD,F,FC,BOOST_PP_DEC(N),MinArity>
|
Chris@16
|
335 {
|
Chris@16
|
336 using forward_adapter_impl<MD,F,FC,BOOST_PP_DEC(N),MinArity>::operator();
|
Chris@16
|
337
|
Chris@16
|
338 # endif
|
Chris@16
|
339
|
Chris@16
|
340 # // Zero based count for each arity would be I-(1<<N)+2, but we don't
|
Chris@16
|
341 # // need it, unless we need a nicer order.
|
Chris@16
|
342
|
Chris@16
|
343 # // Macros for the parameter's type modifiers.
|
Chris@16
|
344 # if I & 0x000001
|
Chris@16
|
345 # define PT0 T0 &
|
Chris@16
|
346 # else
|
Chris@16
|
347 # define PT0 T0 const &
|
Chris@16
|
348 # endif
|
Chris@16
|
349 # if I & 0x000002
|
Chris@16
|
350 # define PT1 T1 &
|
Chris@16
|
351 # else
|
Chris@16
|
352 # define PT1 T1 const &
|
Chris@16
|
353 # endif
|
Chris@16
|
354 # if I & 0x000004
|
Chris@16
|
355 # define PT2 T2 &
|
Chris@16
|
356 # else
|
Chris@16
|
357 # define PT2 T2 const &
|
Chris@16
|
358 # endif
|
Chris@16
|
359 # if I & 0x000008
|
Chris@16
|
360 # define PT3 T3 &
|
Chris@16
|
361 # else
|
Chris@16
|
362 # define PT3 T3 const &
|
Chris@16
|
363 # endif
|
Chris@16
|
364 # if I & 0x000010
|
Chris@16
|
365 # define PT4 T4 &
|
Chris@16
|
366 # else
|
Chris@16
|
367 # define PT4 T4 const &
|
Chris@16
|
368 # endif
|
Chris@16
|
369 # if I & 0x000020
|
Chris@16
|
370 # define PT5 T5 &
|
Chris@16
|
371 # else
|
Chris@16
|
372 # define PT5 T5 const &
|
Chris@16
|
373 # endif
|
Chris@16
|
374 # if I & 0x000040
|
Chris@16
|
375 # define PT6 T6 &
|
Chris@16
|
376 # else
|
Chris@16
|
377 # define PT6 T6 const &
|
Chris@16
|
378 # endif
|
Chris@16
|
379 # if I & 0x000080
|
Chris@16
|
380 # define PT7 T7 &
|
Chris@16
|
381 # else
|
Chris@16
|
382 # define PT7 T7 const &
|
Chris@16
|
383 # endif
|
Chris@16
|
384 # if I & 0x000100
|
Chris@16
|
385 # define PT8 T8 &
|
Chris@16
|
386 # else
|
Chris@16
|
387 # define PT8 T8 const &
|
Chris@16
|
388 # endif
|
Chris@16
|
389 # if I & 0x000200
|
Chris@16
|
390 # define PT9 T9 &
|
Chris@16
|
391 # else
|
Chris@16
|
392 # define PT9 T9 const &
|
Chris@16
|
393 # endif
|
Chris@16
|
394 # if I & 0x000400
|
Chris@16
|
395 # define PT10 T10 &
|
Chris@16
|
396 # else
|
Chris@16
|
397 # define PT10 T10 const &
|
Chris@16
|
398 # endif
|
Chris@16
|
399 # if I & 0x000800
|
Chris@16
|
400 # define PT11 T11 &
|
Chris@16
|
401 # else
|
Chris@16
|
402 # define PT11 T11 const &
|
Chris@16
|
403 # endif
|
Chris@16
|
404 # if I & 0x001000
|
Chris@16
|
405 # define PT12 T12 &
|
Chris@16
|
406 # else
|
Chris@16
|
407 # define PT12 T12 const &
|
Chris@16
|
408 # endif
|
Chris@16
|
409 # if I & 0x002000
|
Chris@16
|
410 # define PT13 T13 &
|
Chris@16
|
411 # else
|
Chris@16
|
412 # define PT13 T13 const &
|
Chris@16
|
413 # endif
|
Chris@16
|
414 # if I & 0x004000
|
Chris@16
|
415 # define PT14 T14 &
|
Chris@16
|
416 # else
|
Chris@16
|
417 # define PT14 T14 const &
|
Chris@16
|
418 # endif
|
Chris@16
|
419 # if I & 0x008000
|
Chris@16
|
420 # define PT15 T15 &
|
Chris@16
|
421 # else
|
Chris@16
|
422 # define PT15 T15 const &
|
Chris@16
|
423 # endif
|
Chris@16
|
424
|
Chris@16
|
425 # if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
|
Chris@16
|
426 template< BOOST_PP_ENUM_PARAMS(N,typename T) >
|
Chris@16
|
427 inline typename boost::result_of< FC(BOOST_PP_ENUM_PARAMS(N,PT))
|
Chris@16
|
428 >::type
|
Chris@16
|
429 operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const
|
Chris@16
|
430 {
|
Chris@16
|
431 return static_cast<MD const* const>(this)
|
Chris@16
|
432 ->target_function()(BOOST_PP_ENUM_PARAMS(N,a));
|
Chris@16
|
433 }
|
Chris@16
|
434 template< BOOST_PP_ENUM_PARAMS(N,typename T) >
|
Chris@16
|
435 inline typename boost::result_of< F(BOOST_PP_ENUM_PARAMS(N,PT))
|
Chris@16
|
436 >::type
|
Chris@16
|
437 operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a))
|
Chris@16
|
438 {
|
Chris@16
|
439 return static_cast<MD* const>(this)
|
Chris@16
|
440 ->target_function()(BOOST_PP_ENUM_PARAMS(N,a));
|
Chris@16
|
441 }
|
Chris@16
|
442 # else
|
Chris@16
|
443 BOOST_TMP_MACRO(BOOST_PP_ENUM_PARAMS(N,typename T),
|
Chris@16
|
444 BOOST_PP_ENUM_PARAMS(N,PT), BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a),
|
Chris@16
|
445 BOOST_PP_ENUM_PARAMS(N,a) )
|
Chris@16
|
446 // ...generates uglier code but is faster - it caches ENUM_*
|
Chris@16
|
447 # endif
|
Chris@16
|
448
|
Chris@16
|
449 # undef PT0
|
Chris@16
|
450 # undef PT1
|
Chris@16
|
451 # undef PT2
|
Chris@16
|
452 # undef PT3
|
Chris@16
|
453 # undef PT4
|
Chris@16
|
454 # undef PT5
|
Chris@16
|
455 # undef PT6
|
Chris@16
|
456 # undef PT7
|
Chris@16
|
457 # undef PT8
|
Chris@16
|
458 # undef PT9
|
Chris@16
|
459 # undef PT10
|
Chris@16
|
460 # undef PT11
|
Chris@16
|
461 # undef PT12
|
Chris@16
|
462 # undef PT13
|
Chris@16
|
463 # undef PT14
|
Chris@16
|
464 # undef PT15
|
Chris@16
|
465
|
Chris@16
|
466 # endif // I < count
|
Chris@16
|
467
|
Chris@16
|
468 # undef I
|
Chris@16
|
469 # endif // defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
470
|
Chris@16
|
471 #endif // include guard
|
Chris@16
|
472
|