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