1 // Copyright Eric Niebler 2005.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef BOOST_PARAMETER_NESTED_KEYWORD_HPP
7 #define BOOST_PARAMETER_NESTED_KEYWORD_HPP
8 
9 #include <boost/parameter/aux_/name.hpp>
10 #include <boost/parameter/keyword.hpp>
11 #include <boost/parameter/config.hpp>
12 #include <boost/preprocessor/cat.hpp>
13 #include <boost/preprocessor/stringize.hpp>
14 
15 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
16 #define BOOST_PARAMETER_NESTED_KEYWORD_AUX(tag_namespace, q, name, alias)    \
17     namespace tag_namespace                                                  \
18     {                                                                        \
19         template <int Dummy = 0>                                             \
20         struct BOOST_PP_CAT(name, _)                                         \
21         {                                                                    \
22             static BOOST_CONSTEXPR char const* keyword_name()                \
23             {                                                                \
24                 return BOOST_PP_STRINGIZE(name);                             \
25             }                                                                \
26             using _ = BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(                  \
27                 BOOST_PP_CAT(name, _)<Dummy>                                 \
28             );                                                               \
29             using _1 = BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(                 \
30                 BOOST_PP_CAT(name, _)<Dummy>                                 \
31             );                                                               \
32             BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_BINDING(                    \
33                 binding_fn                                                   \
34               , BOOST_PP_CAT(name, _)<Dummy>                                 \
35             );                                                               \
36             BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_VALUE(                      \
37                 fn                                                           \
38               , BOOST_PP_CAT(name, _)<Dummy>                                 \
39             );                                                               \
40             using qualifier = ::boost::parameter::q;                         \
41             static ::boost::parameter::keyword<                              \
42                 BOOST_PP_CAT(name, _)<Dummy>                                 \
43             > const& alias;                                                  \
44         };                                                                   \
45         template <int Dummy>                                                 \
46         ::boost::parameter::keyword<                                         \
47             BOOST_PP_CAT(name, _)<Dummy>                                     \
48         > const& BOOST_PP_CAT(name, _)<Dummy>::alias                         \
49             = ::boost::parameter::keyword<                                   \
50                 BOOST_PP_CAT(name, _)<Dummy>                                 \
51             >::instance;                                                     \
52         typedef BOOST_PP_CAT(name, _)<> name;                                \
53     }                                                                        \
54     namespace                                                                \
55     {                                                                        \
56         ::boost::parameter::keyword<tag_namespace::name> const& name         \
57             = ::boost::parameter::keyword<tag_namespace::name>::instance;    \
58     }
59 /**/
60 #else   // !defined(BOOST_PARAMETER_CAN_USE_MP11)
61 #define BOOST_PARAMETER_NESTED_KEYWORD_AUX(tag_namespace, q, name, alias)    \
62     namespace tag_namespace                                                  \
63     {                                                                        \
64         template <int Dummy = 0>                                             \
65         struct BOOST_PP_CAT(name, _)                                         \
66         {                                                                    \
67             static BOOST_CONSTEXPR char const* keyword_name()                \
68             {                                                                \
69                 return BOOST_PP_STRINGIZE(name);                             \
70             }                                                                \
71             typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(                    \
72                 BOOST_PP_CAT(name, _)<Dummy>                                 \
73             ) _;                                                             \
74             typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(                    \
75                 BOOST_PP_CAT(name, _)<Dummy>                                 \
76             ) _1;                                                            \
77             typedef ::boost::parameter::q qualifier;                         \
78             static ::boost::parameter::keyword<                              \
79                 BOOST_PP_CAT(name, _)<Dummy>                                 \
80             > const& alias;                                                  \
81         };                                                                   \
82         template <int Dummy>                                                 \
83         ::boost::parameter::keyword<                                         \
84             BOOST_PP_CAT(name, _)<Dummy>                                     \
85         > const& BOOST_PP_CAT(name, _)<Dummy>::alias                         \
86             = ::boost::parameter::keyword<                                   \
87                 BOOST_PP_CAT(name, _)<Dummy>                                 \
88             >::instance;                                                     \
89         typedef BOOST_PP_CAT(name, _)<> name;                                \
90     }                                                                        \
91     namespace                                                                \
92     {                                                                        \
93         ::boost::parameter::keyword<tag_namespace::name> const& name         \
94             = ::boost::parameter::keyword<tag_namespace::name>::instance;    \
95     }
96 /**/
97 #endif  // BOOST_PARAMETER_CAN_USE_MP11
98 
99 #include <boost/parameter/aux_/preprocessor/qualifier.hpp>
100 
101 #define BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias)           \
102     BOOST_PARAMETER_NESTED_KEYWORD_AUX(                                      \
103         tag_namespace                                                        \
104       , BOOST_PARAMETER_GET_QUALIFIER(name)                                  \
105       , BOOST_PARAMETER_UNQUALIFIED(name)                                    \
106       , alias                                                                \
107     )
108 /**/
109 
110 #endif  // include guard
111 
112