Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/parameter/name.hpp @ 47

Last change on this file since 47 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 6.0 KB
Line 
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  && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
20
21#  include <boost/utility/enable_if.hpp>
22#  include <boost/mpl/lambda.hpp>
23
24namespace boost { namespace parameter { namespace aux {
25
26// Tag type passed to MPL lambda.
27struct lambda_tag;
28
29struct name_tag_base
30{};
31
32template <class Tag>
33struct name_tag
34{};
35
36template <class T>
37struct is_name_tag
38  : mpl::false_
39{};
40
41}}} // namespace boost::parameter::aux
42
43namespace boost { namespace mpl {
44
45template <class T>
46struct lambda<
47    T
48  , typename 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# 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();                   \
87    }
88# endif
89
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          }                                                         \
99                                                                    \
100          typedef boost::parameter::value_type<                     \
101              boost::mpl::_2, tag, boost::parameter::void_          \
102          > _;                                                      \
103                                                                    \
104          typedef boost::parameter::value_type<                     \
105              boost::mpl::_2, tag, boost::parameter::void_          \
106          > _1;                                                     \
107      };                                                            \
108    }                                                               \
109    BOOST_PARAMETER_NAME_OBJECT(tag_namespace::tag, name)
110
111# define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(tag,namespace)         \
112    (tag, namespace), ~
113
114# define BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name)                   \
115    BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PARAMETER_COMPLEX_NAME_TUPLE1 name))
116
117# define BOOST_PARAMETER_COMPLEX_NAME_TAG(name)                     \
118    BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
119
120# define BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name)               \
121    BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
122
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)                      \
128    )                                                               \
129/**/
130
131# define BOOST_PARAMETER_SIMPLE_NAME(name)                          \
132    BOOST_PARAMETER_BASIC_NAME(tag, name, BOOST_PP_CAT(_, name))
133
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/**/
141
142
143# define BOOST_PARAMETER_TEMPLATE_KEYWORD(name)                     \
144    namespace tag                                                   \
145    {                                                               \
146      struct name;                                                  \
147    }                                                               \
148    template <class T>                                              \
149    struct name                                                     \
150      : boost::parameter::template_keyword<tag::name, T>            \
151    {};                                                             \
152/**/
153
154#endif // BOOST_PARAMETER_NAME_060806_HPP
155
Note: See TracBrowser for help on using the repository browser.