Improve vacpp support.
[boost.git] / boost / boost / parameter / name.hpp
blob932f8af218831a22427d8d22ae2ff6817981f554
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)
5 #ifndef BOOST_PARAMETER_NAME_060806_HPP
6 # define BOOST_PARAMETER_NAME_060806_HPP
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>
18 # if !defined(BOOST_NO_SFINAE) \
19 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
21 # include <boost/utility/enable_if.hpp>
22 # include <boost/mpl/lambda.hpp>
24 namespace boost { namespace parameter { namespace aux {
26 // Tag type passed to MPL lambda.
27 struct lambda_tag;
29 struct name_tag_base
30 {};
32 template <class Tag>
33 struct name_tag
34 {};
36 template <class T>
37 struct is_name_tag
38 : mpl::false_
39 {};
41 }}} // namespace boost::parameter::aux
43 namespace boost { namespace mpl {
45 template <class T>
46 struct lambda<
48 , typename enable_if<
49 parameter::aux::is_name_tag<T>, parameter::aux::lambda_tag
50 >::type
53 typedef true_ is_le;
54 typedef bind3< quote3<parameter::value_type>, arg<2>, T, void> result_;
55 typedef result_ type;
58 }} // namespace boost::mpl
60 # endif
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
77 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
78 # define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
79 static ::boost::parameter::keyword<tag>& name \
80 = ::boost::parameter::keyword<tag>::get();
81 # else
82 # define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
83 namespace \
84 { \
85 ::boost::parameter::keyword<tag>& name \
86 = ::boost::parameter::keyword<tag>::get(); \
88 # endif
90 # define BOOST_PARAMETER_BASIC_NAME(tag_namespace, tag, name) \
91 namespace tag_namespace \
92 { \
93 struct tag \
94 { \
95 static char const* keyword_name() \
96 { \
97 return BOOST_PP_STRINGIZE(tag); \
98 } \
100 typedef boost::parameter::value_type< \
101 boost::mpl::_2, tag, boost::parameter::void_ \
102 > _; \
104 typedef boost::parameter::value_type< \
105 boost::mpl::_2, tag, boost::parameter::void_ \
106 > _1; \
107 }; \
109 BOOST_PARAMETER_NAME_OBJECT(tag_namespace::tag, name)
111 # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(tag,namespace) \
112 (tag, namespace), ~
114 # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name) \
115 BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PARAMETER_COMPLEX_NAME_TUPLE1 name))
117 # define BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
118 BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
120 # define BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
121 BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
123 # define BOOST_PARAMETER_COMPLEX_NAME(name) \
124 BOOST_PARAMETER_BASIC_NAME( \
125 BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
126 , BOOST_PP_TUPLE_EAT(2) name \
127 , BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
129 /**/
131 # define BOOST_PARAMETER_SIMPLE_NAME(name) \
132 BOOST_PARAMETER_BASIC_NAME(tag, name, BOOST_PP_CAT(_, name))
134 # define BOOST_PARAMETER_NAME(name) \
135 BOOST_PP_IIF( \
136 BOOST_PARAMETER_IS_BINARY(name) \
137 , BOOST_PARAMETER_COMPLEX_NAME \
138 , BOOST_PARAMETER_SIMPLE_NAME \
139 )(name) \
140 /**/
143 # define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \
144 namespace tag \
146 struct name; \
148 template <class T> \
149 struct name \
150 : boost::parameter::template_keyword<tag::name, T> \
151 {}; \
152 /**/
154 #endif // BOOST_PARAMETER_NAME_060806_HPP