Chris@16
|
1 // Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
|
Chris@16
|
2 // distribution is subject to the Boost Software License, Version 1.0.
|
Chris@16
|
3 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_PARAMETER_MACROS_050412_HPP
|
Chris@16
|
7 #define BOOST_PARAMETER_MACROS_050412_HPP
|
Chris@16
|
8
|
Chris@16
|
9 #include <boost/preprocessor/tuple/elem.hpp>
|
Chris@16
|
10 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
Chris@16
|
11 #include <boost/preprocessor/arithmetic/inc.hpp>
|
Chris@16
|
12 #include <boost/preprocessor/logical/bool.hpp>
|
Chris@16
|
13 #include <boost/preprocessor/punctuation/comma_if.hpp>
|
Chris@16
|
14 #include <boost/preprocessor/control/expr_if.hpp>
|
Chris@16
|
15 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
16 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
Chris@16
|
17 #include <boost/preprocessor/cat.hpp>
|
Chris@16
|
18 #include <boost/detail/workaround.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #define BOOST_PARAMETER_FUN_TEMPLATE_HEAD1(n) \
|
Chris@16
|
21 template<BOOST_PP_ENUM_PARAMS(n, class T)>
|
Chris@16
|
22
|
Chris@16
|
23 #define BOOST_PARAMETER_FUN_TEMPLATE_HEAD0(n)
|
Chris@16
|
24
|
Chris@16
|
25 #if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
Chris@16
|
26
|
Chris@16
|
27 # define BOOST_PARAMETER_MATCH_TYPE(n, param) \
|
Chris@16
|
28 BOOST_PP_EXPR_IF(n, typename) param::match \
|
Chris@16
|
29 < \
|
Chris@16
|
30 BOOST_PP_ENUM_PARAMS(n, T) \
|
Chris@16
|
31 >::type
|
Chris@16
|
32
|
Chris@16
|
33 #else
|
Chris@16
|
34
|
Chris@16
|
35 # define BOOST_PARAMETER_MATCH_TYPE(n, param) param
|
Chris@16
|
36
|
Chris@16
|
37 #endif
|
Chris@16
|
38
|
Chris@16
|
39 #define BOOST_PARAMETER_FUN_DECL(z, n, params) \
|
Chris@16
|
40 \
|
Chris@16
|
41 BOOST_PP_CAT(BOOST_PARAMETER_FUN_TEMPLATE_HEAD, BOOST_PP_BOOL(n))(n) \
|
Chris@16
|
42 \
|
Chris@16
|
43 BOOST_PP_TUPLE_ELEM(3, 0, params) \
|
Chris@16
|
44 BOOST_PP_TUPLE_ELEM(3, 1, params)( \
|
Chris@16
|
45 BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& p) \
|
Chris@16
|
46 BOOST_PP_COMMA_IF(n) \
|
Chris@16
|
47 BOOST_PARAMETER_MATCH_TYPE(n,BOOST_PP_TUPLE_ELEM(3, 2, params)) \
|
Chris@16
|
48 kw = BOOST_PP_TUPLE_ELEM(3, 2, params)() \
|
Chris@16
|
49 ) \
|
Chris@16
|
50 { \
|
Chris@16
|
51 return BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 1, params), _with_named_params)( \
|
Chris@16
|
52 kw(BOOST_PP_ENUM_PARAMS(n, p)) \
|
Chris@16
|
53 ); \
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56 // Generates:
|
Chris@16
|
57 //
|
Chris@16
|
58 // template<class Params>
|
Chris@16
|
59 // ret name ## _with_named_params(Params const&);
|
Chris@16
|
60 //
|
Chris@16
|
61 // template<class T0>
|
Chris@16
|
62 // ret name(T0 const& p0, typename parameters::match<T0>::type kw = parameters())
|
Chris@16
|
63 // {
|
Chris@16
|
64 // return name ## _with_named_params(kw(p0));
|
Chris@16
|
65 // }
|
Chris@16
|
66 //
|
Chris@16
|
67 // template<class T0, ..., class TN>
|
Chris@16
|
68 // ret name(T0 const& p0, ..., TN const& PN
|
Chris@16
|
69 // , typename parameters::match<T0, ..., TN>::type kw = parameters())
|
Chris@16
|
70 // {
|
Chris@16
|
71 // return name ## _with_named_params(kw(p0, ..., pN));
|
Chris@16
|
72 // }
|
Chris@16
|
73 //
|
Chris@16
|
74 // template<class Params>
|
Chris@16
|
75 // ret name ## _with_named_params(Params const&)
|
Chris@16
|
76 //
|
Chris@16
|
77 // lo and hi determines the min and max arity of the generated functions.
|
Chris@16
|
78
|
Chris@16
|
79 #define BOOST_PARAMETER_FUN(ret, name, lo, hi, parameters) \
|
Chris@16
|
80 \
|
Chris@16
|
81 template<class Params> \
|
Chris@16
|
82 ret BOOST_PP_CAT(name, _with_named_params)(Params const& p); \
|
Chris@16
|
83 \
|
Chris@16
|
84 BOOST_PP_REPEAT_FROM_TO( \
|
Chris@16
|
85 lo, BOOST_PP_INC(hi), BOOST_PARAMETER_FUN_DECL, (ret, name, parameters)) \
|
Chris@16
|
86 \
|
Chris@16
|
87 template<class Params> \
|
Chris@16
|
88 ret BOOST_PP_CAT(name, _with_named_params)(Params const& p)
|
Chris@16
|
89
|
Chris@16
|
90 #define BOOST_PARAMETER_MEMFUN(ret, name, lo, hi, parameters) \
|
Chris@16
|
91 \
|
Chris@16
|
92 BOOST_PP_REPEAT_FROM_TO( \
|
Chris@16
|
93 lo, BOOST_PP_INC(hi), BOOST_PARAMETER_FUN_DECL, (ret, name, parameters)) \
|
Chris@16
|
94 \
|
Chris@16
|
95 template<class Params> \
|
Chris@16
|
96 ret BOOST_PP_CAT(name, _with_named_params)(Params const& p)
|
Chris@16
|
97
|
Chris@16
|
98 #endif // BOOST_PARAMETER_MACROS_050412_HPP
|
Chris@16
|
99
|