name.hpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. #ifndef BOOST_PARAMETER_NAME_060806_HPP
  5. # define BOOST_PARAMETER_NAME_060806_HPP
  6. # include <boost/parameter/keyword.hpp>
  7. # include <boost/parameter/value_type.hpp>
  8. # include <boost/detail/workaround.hpp>
  9. # include <boost/preprocessor/cat.hpp>
  10. # include <boost/preprocessor/stringize.hpp>
  11. # include <boost/preprocessor/control/iif.hpp>
  12. # include <boost/preprocessor/tuple/eat.hpp>
  13. # include <boost/preprocessor/tuple/elem.hpp>
  14. # include <boost/mpl/placeholders.hpp>
  15. # if !defined(BOOST_NO_SFINAE) \
  16. && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
  17. && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
  18. # include <boost/utility/enable_if.hpp>
  19. # include <boost/mpl/lambda.hpp>
  20. namespace boost { namespace parameter { namespace aux {
  21. // Tag type passed to MPL lambda.
  22. struct lambda_tag;
  23. struct name_tag_base
  24. {};
  25. template <class Tag>
  26. struct name_tag
  27. {};
  28. template <class T>
  29. struct is_name_tag
  30. : mpl::false_
  31. {};
  32. }}} // namespace boost::parameter::aux
  33. namespace boost { namespace mpl {
  34. template <class T>
  35. struct lambda<
  36. T
  37. , typename enable_if<
  38. parameter::aux::is_name_tag<T>, parameter::aux::lambda_tag
  39. >::type
  40. >
  41. {
  42. typedef true_ is_le;
  43. typedef bind3< quote3<parameter::value_type>, arg<2>, T, void> result_;
  44. typedef result_ type;
  45. };
  46. }} // namespace boost::mpl
  47. # endif
  48. # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  49. # include <boost/preprocessor/detail/split.hpp>
  50. // From Paul Mensonides
  51. # define BOOST_PARAMETER_IS_BINARY(x) \
  52. BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_BINARY_C x BOOST_PP_COMMA() 0) \
  53. /**/
  54. # define BOOST_PARAMETER_IS_BINARY_C(x,y) \
  55. ~, 1 BOOST_PP_RPAREN() \
  56. BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ \
  57. /**/
  58. # else
  59. # include <boost/preprocessor/detail/is_binary.hpp>
  60. # define BOOST_PARAMETER_IS_BINARY(x) BOOST_PP_IS_BINARY(x)
  61. # endif
  62. # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  63. # define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
  64. static ::boost::parameter::keyword<tag> const& name \
  65. = ::boost::parameter::keyword<tag>::instance;
  66. # else
  67. # define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
  68. namespace \
  69. { \
  70. ::boost::parameter::keyword<tag> const& name \
  71. = ::boost::parameter::keyword<tag>::instance; \
  72. }
  73. # endif
  74. # define BOOST_PARAMETER_BASIC_NAME(tag_namespace, tag, name) \
  75. namespace tag_namespace \
  76. { \
  77. struct tag \
  78. { \
  79. static char const* keyword_name() \
  80. { \
  81. return BOOST_PP_STRINGIZE(tag); \
  82. } \
  83. \
  84. typedef boost::parameter::value_type< \
  85. boost::mpl::_2, tag, boost::parameter::void_ \
  86. > _; \
  87. \
  88. typedef boost::parameter::value_type< \
  89. boost::mpl::_2, tag, boost::parameter::void_ \
  90. > _1; \
  91. }; \
  92. } \
  93. BOOST_PARAMETER_NAME_OBJECT(tag_namespace::tag, name)
  94. # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(tag,namespace) \
  95. (tag, namespace), ~
  96. # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name) \
  97. BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PARAMETER_COMPLEX_NAME_TUPLE1 name))
  98. # define BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
  99. BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
  100. # define BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
  101. BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
  102. # define BOOST_PARAMETER_COMPLEX_NAME(name) \
  103. BOOST_PARAMETER_BASIC_NAME( \
  104. BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
  105. , BOOST_PP_TUPLE_EAT(2) name \
  106. , BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
  107. ) \
  108. /**/
  109. # define BOOST_PARAMETER_SIMPLE_NAME(name) \
  110. BOOST_PARAMETER_BASIC_NAME(tag, name, BOOST_PP_CAT(_, name))
  111. # define BOOST_PARAMETER_NAME(name) \
  112. BOOST_PP_IIF( \
  113. BOOST_PARAMETER_IS_BINARY(name) \
  114. , BOOST_PARAMETER_COMPLEX_NAME \
  115. , BOOST_PARAMETER_SIMPLE_NAME \
  116. )(name) \
  117. /**/
  118. # define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \
  119. namespace tag \
  120. { \
  121. struct name; \
  122. } \
  123. template <class T> \
  124. struct name \
  125. : boost::parameter::template_keyword<tag::name, T> \
  126. {}; \
  127. /**/
  128. #endif // BOOST_PARAMETER_NAME_060806_HPP