name.hpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright Daniel Wallin 2006.
  2. // Copyright Cromwell D. Enage 2017.
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_PARAMETER_NAME_060806_HPP
  7. #define BOOST_PARAMETER_NAME_060806_HPP
  8. #include <boost/parameter/aux_/name.hpp>
  9. #include <boost/preprocessor/stringize.hpp>
  10. #include <boost/config.hpp>
  11. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  12. #define BOOST_PARAMETER_NAME_TAG(tag_namespace, tag, q) \
  13. namespace tag_namespace \
  14. { \
  15. struct tag \
  16. { \
  17. static BOOST_CONSTEXPR char const* keyword_name() \
  18. { \
  19. return BOOST_PP_STRINGIZE(tag); \
  20. } \
  21. using _ = BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(tag); \
  22. using _1 = _; \
  23. BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_BINDING(binding_fn, tag); \
  24. BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_VALUE(fn, tag); \
  25. using qualifier = ::boost::parameter::q; \
  26. }; \
  27. }
  28. /**/
  29. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  30. #define BOOST_PARAMETER_NAME_TAG(tag_namespace, tag, q) \
  31. namespace tag_namespace \
  32. { \
  33. struct tag \
  34. { \
  35. static BOOST_CONSTEXPR char const* keyword_name() \
  36. { \
  37. return BOOST_PP_STRINGIZE(tag); \
  38. } \
  39. typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(tag) _; \
  40. typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(tag) _1; \
  41. typedef ::boost::parameter::q qualifier; \
  42. }; \
  43. }
  44. /**/
  45. #endif // BOOST_PARAMETER_CAN_USE_MP11
  46. #include <boost/parameter/keyword.hpp>
  47. #define BOOST_PARAMETER_NAME_KEYWORD(tag_namespace, tag, name) \
  48. namespace \
  49. { \
  50. ::boost::parameter::keyword<tag_namespace::tag> const& name \
  51. = ::boost::parameter::keyword<tag_namespace::tag>::instance; \
  52. }
  53. /**/
  54. #define BOOST_PARAMETER_BASIC_NAME(tag_namespace, tag, qualifier, name) \
  55. BOOST_PARAMETER_NAME_TAG(tag_namespace, tag, qualifier) \
  56. BOOST_PARAMETER_NAME_KEYWORD(tag_namespace, tag, name)
  57. /**/
  58. #define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(object, namespace) \
  59. (object, namespace), ~
  60. /**/
  61. #include <boost/preprocessor/tuple/elem.hpp>
  62. #define BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name) \
  63. BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PARAMETER_COMPLEX_NAME_TUPLE1 name))
  64. /**/
  65. #define BOOST_PARAMETER_COMPLEX_NAME_OBJECT(name) \
  66. BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
  67. /**/
  68. #define BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
  69. BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
  70. /**/
  71. #include <boost/parameter/aux_/preprocessor/qualifier.hpp>
  72. #include <boost/preprocessor/tuple/eat.hpp>
  73. #define BOOST_PARAMETER_COMPLEX_NAME(name) \
  74. BOOST_PARAMETER_BASIC_NAME( \
  75. BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
  76. , BOOST_PARAMETER_UNQUALIFIED(BOOST_PP_TUPLE_EAT(2) name) \
  77. , BOOST_PARAMETER_GET_QUALIFIER(BOOST_PP_TUPLE_EAT(2) name) \
  78. , BOOST_PARAMETER_COMPLEX_NAME_OBJECT(name) \
  79. )
  80. /**/
  81. #include <boost/preprocessor/cat.hpp>
  82. #define BOOST_PARAMETER_SIMPLE_NAME(name) \
  83. BOOST_PARAMETER_BASIC_NAME( \
  84. tag \
  85. , BOOST_PARAMETER_UNQUALIFIED(name) \
  86. , BOOST_PARAMETER_GET_QUALIFIER(name) \
  87. , BOOST_PP_CAT(_, BOOST_PARAMETER_UNQUALIFIED(name)) \
  88. )
  89. /**/
  90. #include <boost/parameter/aux_/preprocessor/is_binary.hpp>
  91. #include <boost/preprocessor/control/iif.hpp>
  92. #define BOOST_PARAMETER_NAME(name) \
  93. BOOST_PP_IIF( \
  94. BOOST_PARAMETER_IS_BINARY(name) \
  95. , BOOST_PARAMETER_COMPLEX_NAME \
  96. , BOOST_PARAMETER_SIMPLE_NAME \
  97. )(name)
  98. /**/
  99. #include <boost/parameter/template_keyword.hpp>
  100. #endif // include guard