function_name.hpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // Copyright Daniel Wallin 2006.
  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_AUX_PREPROCESSOR_IMPL_FUNCTION_NAME_HPP
  6. #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_NAME_HPP
  7. #define BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_static ()
  8. /**/
  9. #include <boost/parameter/aux_/preprocessor/is_nullary.hpp>
  10. #include <boost/preprocessor/cat.hpp>
  11. #define BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \
  12. BOOST_PARAMETER_IS_NULLARY( \
  13. BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_, name) \
  14. )
  15. /**/
  16. #include <boost/preprocessor/seq/seq.hpp>
  17. #include <boost/config.hpp>
  18. #if defined(BOOST_MSVC)
  19. // Workaround for MSVC preprocessor.
  20. //
  21. // When stripping static from "static f", msvc will produce " f". The leading
  22. // whitespace doesn't go away when pasting the token with something else, so
  23. // this thing is a hack to strip the whitespace.
  24. #define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static (
  25. /**/
  26. #define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \
  27. BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name))
  28. /**/
  29. #define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \
  30. BOOST_PP_SEQ_HEAD( \
  31. BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \
  32. )
  33. /**/
  34. #else
  35. #define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static
  36. /**/
  37. #define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \
  38. BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name)
  39. /**/
  40. #endif // MSVC workarounds needed
  41. #include <boost/preprocessor/control/expr_if.hpp>
  42. #define BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \
  43. BOOST_PP_EXPR_IF( \
  44. BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name), static \
  45. )
  46. /**/
  47. #include <boost/preprocessor/control/if.hpp>
  48. #include <boost/preprocessor/tuple/eat.hpp>
  49. #define BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name) \
  50. BOOST_PP_IF( \
  51. BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \
  52. , BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC \
  53. , name BOOST_PP_TUPLE_EAT(1) \
  54. )(name)
  55. /**/
  56. // Produces a name for a parameter specification for the function named base.
  57. #define BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME(base, is_const) \
  58. BOOST_PP_CAT( \
  59. BOOST_PP_CAT( \
  60. BOOST_PP_IF( \
  61. is_const \
  62. , boost_param_parameters_const_ \
  63. , boost_param_parameters_ \
  64. ) \
  65. , __LINE__ \
  66. ) \
  67. , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \
  68. )
  69. /**/
  70. // Produces a name for a result type metafunction for the no-spec function
  71. // named base.
  72. #define BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(base, is_const) \
  73. BOOST_PP_CAT( \
  74. BOOST_PP_CAT( \
  75. BOOST_PP_IF( \
  76. is_const \
  77. , boost_param_no_spec_result_const_ \
  78. , boost_param_no_spec_result_ \
  79. ) \
  80. , __LINE__ \
  81. ) \
  82. , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \
  83. )
  84. /**/
  85. // Produces a name for a result type metafunction for the function named base.
  86. #define BOOST_PARAMETER_FUNCTION_RESULT_NAME(base, is_const) \
  87. BOOST_PP_CAT( \
  88. BOOST_PP_CAT( \
  89. BOOST_PP_IF( \
  90. is_const \
  91. , boost_param_result_const_ \
  92. , boost_param_result_ \
  93. ) \
  94. , __LINE__ \
  95. ) \
  96. , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \
  97. )
  98. /**/
  99. // Produces a name for the implementation function to which the no-spec
  100. // function named base forwards its result type and argument pack.
  101. #define BOOST_PARAMETER_NO_SPEC_FUNCTION_IMPL_NAME(base, is_const) \
  102. BOOST_PP_CAT( \
  103. BOOST_PP_CAT( \
  104. BOOST_PP_IF( \
  105. is_const \
  106. , boost_param_no_spec_impl_const \
  107. , boost_param_no_spec_impl \
  108. ) \
  109. , __LINE__ \
  110. ) \
  111. , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \
  112. )
  113. /**/
  114. // Can't do boost_param_impl_ ## basee
  115. // because base might start with an underscore.
  116. // daniel: what? how is that relevant? the reason for using CAT()
  117. // is to make sure base is expanded. i'm not sure we need to here,
  118. // but it's more stable to do it.
  119. #define BOOST_PARAMETER_FUNCTION_IMPL_NAME(base, is_const) \
  120. BOOST_PP_CAT( \
  121. BOOST_PP_CAT( \
  122. BOOST_PP_IF(is_const, boost_param_impl_const, boost_param_impl) \
  123. , __LINE__ \
  124. ) \
  125. , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \
  126. )
  127. /**/
  128. #endif // include guard