nested_keyword.hpp 7.0 KB

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