Chris@16
|
1 // Copyright Daniel Wallin 2006. Use, modification and distribution is
|
Chris@16
|
2 // subject to the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
4
|
Chris@16
|
5 #ifndef BOOST_PARAMETER_NAME_060806_HPP
|
Chris@16
|
6 # define BOOST_PARAMETER_NAME_060806_HPP
|
Chris@16
|
7
|
Chris@16
|
8 # include <boost/parameter/keyword.hpp>
|
Chris@16
|
9 # include <boost/parameter/value_type.hpp>
|
Chris@16
|
10 # include <boost/detail/workaround.hpp>
|
Chris@16
|
11 # include <boost/preprocessor/cat.hpp>
|
Chris@16
|
12 # include <boost/preprocessor/stringize.hpp>
|
Chris@16
|
13 # include <boost/preprocessor/control/iif.hpp>
|
Chris@16
|
14 # include <boost/preprocessor/tuple/eat.hpp>
|
Chris@16
|
15 # include <boost/preprocessor/tuple/elem.hpp>
|
Chris@16
|
16 # include <boost/mpl/placeholders.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 # if !defined(BOOST_NO_SFINAE) \
|
Chris@16
|
19 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
Chris@16
|
20 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
Chris@16
|
21
|
Chris@16
|
22 # include <boost/utility/enable_if.hpp>
|
Chris@16
|
23 # include <boost/mpl/lambda.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost { namespace parameter { namespace aux {
|
Chris@16
|
26
|
Chris@16
|
27 // Tag type passed to MPL lambda.
|
Chris@16
|
28 struct lambda_tag;
|
Chris@16
|
29
|
Chris@16
|
30 struct name_tag_base
|
Chris@16
|
31 {};
|
Chris@16
|
32
|
Chris@16
|
33 template <class Tag>
|
Chris@16
|
34 struct name_tag
|
Chris@16
|
35 {};
|
Chris@16
|
36
|
Chris@16
|
37 template <class T>
|
Chris@16
|
38 struct is_name_tag
|
Chris@16
|
39 : mpl::false_
|
Chris@16
|
40 {};
|
Chris@16
|
41
|
Chris@16
|
42 }}} // namespace boost::parameter::aux
|
Chris@16
|
43
|
Chris@16
|
44 namespace boost { namespace mpl {
|
Chris@16
|
45
|
Chris@16
|
46 template <class T>
|
Chris@16
|
47 struct lambda<
|
Chris@16
|
48 T
|
Chris@16
|
49 , typename boost::enable_if<
|
Chris@16
|
50 parameter::aux::is_name_tag<T>, parameter::aux::lambda_tag
|
Chris@16
|
51 >::type
|
Chris@16
|
52 >
|
Chris@16
|
53 {
|
Chris@16
|
54 typedef true_ is_le;
|
Chris@16
|
55 typedef bind3< quote3<parameter::value_type>, arg<2>, T, void> result_;
|
Chris@16
|
56 typedef result_ type;
|
Chris@16
|
57 };
|
Chris@16
|
58
|
Chris@16
|
59 }} // namespace boost::mpl
|
Chris@16
|
60
|
Chris@16
|
61 # endif
|
Chris@16
|
62
|
Chris@16
|
63 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
Chris@16
|
64 # include <boost/preprocessor/detail/split.hpp>
|
Chris@16
|
65 // From Paul Mensonides
|
Chris@16
|
66 # define BOOST_PARAMETER_IS_BINARY(x) \
|
Chris@16
|
67 BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_BINARY_C x BOOST_PP_COMMA() 0) \
|
Chris@16
|
68 /**/
|
Chris@16
|
69 # define BOOST_PARAMETER_IS_BINARY_C(x,y) \
|
Chris@16
|
70 ~, 1 BOOST_PP_RPAREN() \
|
Chris@16
|
71 BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ \
|
Chris@16
|
72 /**/
|
Chris@16
|
73 # else
|
Chris@16
|
74 # include <boost/preprocessor/detail/is_binary.hpp>
|
Chris@16
|
75 # define BOOST_PARAMETER_IS_BINARY(x) BOOST_PP_IS_BINARY(x)
|
Chris@16
|
76 # endif
|
Chris@16
|
77
|
Chris@16
|
78 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
Chris@16
|
79 # define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
|
Chris@16
|
80 static ::boost::parameter::keyword<tag> const& name \
|
Chris@16
|
81 = ::boost::parameter::keyword<tag>::instance;
|
Chris@16
|
82 # else
|
Chris@16
|
83 # define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
|
Chris@16
|
84 namespace \
|
Chris@16
|
85 { \
|
Chris@16
|
86 ::boost::parameter::keyword<tag> const& name \
|
Chris@16
|
87 = ::boost::parameter::keyword<tag>::instance; \
|
Chris@16
|
88 }
|
Chris@16
|
89 # endif
|
Chris@16
|
90
|
Chris@16
|
91 # define BOOST_PARAMETER_BASIC_NAME(tag_namespace, tag, name) \
|
Chris@16
|
92 namespace tag_namespace \
|
Chris@16
|
93 { \
|
Chris@16
|
94 struct tag \
|
Chris@16
|
95 { \
|
Chris@16
|
96 static char const* keyword_name() \
|
Chris@16
|
97 { \
|
Chris@16
|
98 return BOOST_PP_STRINGIZE(tag); \
|
Chris@16
|
99 } \
|
Chris@16
|
100 \
|
Chris@16
|
101 typedef boost::parameter::value_type< \
|
Chris@16
|
102 boost::mpl::_2, tag, boost::parameter::void_ \
|
Chris@16
|
103 > _; \
|
Chris@16
|
104 \
|
Chris@16
|
105 typedef boost::parameter::value_type< \
|
Chris@16
|
106 boost::mpl::_2, tag, boost::parameter::void_ \
|
Chris@16
|
107 > _1; \
|
Chris@16
|
108 }; \
|
Chris@16
|
109 } \
|
Chris@16
|
110 BOOST_PARAMETER_NAME_OBJECT(tag_namespace::tag, name)
|
Chris@16
|
111
|
Chris@16
|
112 # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(tag,namespace) \
|
Chris@16
|
113 (tag, namespace), ~
|
Chris@16
|
114
|
Chris@16
|
115 # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name) \
|
Chris@16
|
116 BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PARAMETER_COMPLEX_NAME_TUPLE1 name))
|
Chris@16
|
117
|
Chris@16
|
118 # define BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
|
Chris@16
|
119 BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
|
Chris@16
|
120
|
Chris@16
|
121 # define BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
|
Chris@16
|
122 BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
|
Chris@16
|
123
|
Chris@16
|
124 # define BOOST_PARAMETER_COMPLEX_NAME(name) \
|
Chris@16
|
125 BOOST_PARAMETER_BASIC_NAME( \
|
Chris@16
|
126 BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
|
Chris@16
|
127 , BOOST_PP_TUPLE_EAT(2) name \
|
Chris@16
|
128 , BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
|
Chris@16
|
129 ) \
|
Chris@16
|
130 /**/
|
Chris@16
|
131
|
Chris@16
|
132 # define BOOST_PARAMETER_SIMPLE_NAME(name) \
|
Chris@16
|
133 BOOST_PARAMETER_BASIC_NAME(tag, name, BOOST_PP_CAT(_, name))
|
Chris@16
|
134
|
Chris@16
|
135 # define BOOST_PARAMETER_NAME(name) \
|
Chris@16
|
136 BOOST_PP_IIF( \
|
Chris@16
|
137 BOOST_PARAMETER_IS_BINARY(name) \
|
Chris@16
|
138 , BOOST_PARAMETER_COMPLEX_NAME \
|
Chris@16
|
139 , BOOST_PARAMETER_SIMPLE_NAME \
|
Chris@16
|
140 )(name) \
|
Chris@16
|
141 /**/
|
Chris@16
|
142
|
Chris@16
|
143
|
Chris@16
|
144 # define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \
|
Chris@16
|
145 namespace tag \
|
Chris@16
|
146 { \
|
Chris@16
|
147 struct name; \
|
Chris@16
|
148 } \
|
Chris@16
|
149 template <class T> \
|
Chris@16
|
150 struct name \
|
Chris@16
|
151 : boost::parameter::template_keyword<tag::name, T> \
|
Chris@16
|
152 {}; \
|
Chris@16
|
153 /**/
|
Chris@16
|
154
|
Chris@16
|
155 #endif // BOOST_PARAMETER_NAME_060806_HPP
|
Chris@16
|
156
|