preprocessor.hpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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_PREPROCESSOR_060206_HPP
  7. #define BOOST_PARAMETER_PREPROCESSOR_060206_HPP
  8. #include <boost/parameter/aux_/preprocessor/impl/forwarding_overloads.hpp>
  9. #include <boost/parameter/aux_/preprocessor/impl/specification.hpp>
  10. #include <boost/preprocessor/cat.hpp>
  11. // Helper macro for BOOST_PARAMETER_CONSTRUCTOR.
  12. #define BOOST_PARAMETER_CONSTRUCTOR_AUX(class_, base, tag_namespace, args) \
  13. BOOST_PARAMETER_SPECIFICATION(tag_namespace, ctor, args, 0) \
  14. BOOST_PP_CAT(constructor_parameters, __LINE__); \
  15. BOOST_PARAMETER_CONSTRUCTOR_OVERLOADS(class_, base, args)
  16. /**/
  17. #include <boost/parameter/aux_/preprocessor/impl/function_name.hpp>
  18. // Defines the implementation function header.
  19. #define BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name, is_const) \
  20. template <typename Args> \
  21. typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name, is_const)< \
  22. Args \
  23. >::type BOOST_PARAMETER_FUNCTION_IMPL_NAME(name, is_const)( \
  24. Args const& args \
  25. )
  26. /**/
  27. #include <boost/parameter/aux_/preprocessor/impl/parenthesized_return_type.hpp>
  28. #include <boost/parameter/config.hpp>
  29. // Expands to the result metafunction and the parameters specialization.
  30. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  31. #define BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_ns, args, is_const) \
  32. template <typename Args> \
  33. using BOOST_PARAMETER_FUNCTION_RESULT_NAME(name, is_const) \
  34. = typename BOOST_PARAMETER_PARENTHESIZED_RETURN_TYPE(result); \
  35. BOOST_PARAMETER_SPECIFICATION(tag_ns, name, args, is_const) \
  36. BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME(name, is_const);
  37. /**/
  38. #else
  39. #define BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_ns, args, is_const) \
  40. template <typename Args> \
  41. struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name, is_const) \
  42. : BOOST_PARAMETER_PARENTHESIZED_RETURN_TYPE(result) \
  43. { \
  44. }; \
  45. BOOST_PARAMETER_SPECIFICATION(tag_ns, name, args, is_const) \
  46. BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME(name, is_const);
  47. /**/
  48. #endif // BOOST_PARAMETER_CAN_USE_MP11
  49. // Helper macro for BOOST_PARAMETER_BASIC_FUNCTION.
  50. #define BOOST_PARAMETER_BASIC_FUNCTION_AUX(result, name, tag_ns, args) \
  51. BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_ns, args, 0) \
  52. BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name, 0); \
  53. BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, name, args, 0, 0) \
  54. BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name, 0)
  55. /**/
  56. #include <boost/preprocessor/control/expr_if.hpp>
  57. // Helper macro for BOOST_PARAMETER_BASIC_MEMBER_FUNCTION,
  58. // BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION,
  59. // BOOST_PARAMETER_BASIC_FUNCTION_CALL_OPERATOR, and
  60. // BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR.
  61. #define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX(r, n, i, tag_ns, args, c) \
  62. BOOST_PARAMETER_FUNCTION_HEAD(r, i, tag_ns, args, c) \
  63. BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(n, i, args, 1, c) \
  64. BOOST_PARAMETER_FUNCTION_IMPL_HEAD(i, c) BOOST_PP_EXPR_IF(c, const)
  65. /**/
  66. #include <boost/parameter/aux_/preprocessor/impl/flatten.hpp>
  67. // Expands to a Boost.Parameter-enabled constructor header. All arguments are
  68. // accessible via args and keywords only.
  69. #define BOOST_PARAMETER_CONSTRUCTOR(class_, base, tag_namespace, args) \
  70. BOOST_PARAMETER_CONSTRUCTOR_AUX( \
  71. class_, base, tag_namespace \
  72. , BOOST_PARAMETER_AUX_PP_FLATTEN(2, 2, 3, args) \
  73. )
  74. /**/
  75. // Expands to a Boost.Parameter-enabled function header. All arguments are
  76. // accessible via args and keywords only.
  77. #define BOOST_PARAMETER_BASIC_FUNCTION(result, name, tag_namespace, args) \
  78. BOOST_PARAMETER_BASIC_FUNCTION_AUX( \
  79. result, name, tag_namespace \
  80. , BOOST_PARAMETER_AUX_PP_FLATTEN(2, 2, 3, args) \
  81. )
  82. /**/
  83. // Expands to a Boost.Parameter-enabled member function header. All arguments
  84. // are accessible via args and keywords only.
  85. #define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION(result, name, tag_ns, args) \
  86. BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \
  87. result, name, name, tag_ns \
  88. , BOOST_PARAMETER_AUX_PP_FLATTEN(2, 2, 3, args), 0 \
  89. )
  90. /**/
  91. // Expands to a Boost.Parameter-enabled const-qualified member function
  92. // header. All arguments are accessible via args and keywords only.
  93. #define BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION(r, name, tag_ns, args) \
  94. BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \
  95. r, name, name, tag_ns \
  96. , BOOST_PARAMETER_AUX_PP_FLATTEN(2, 2, 3, args), 1 \
  97. )
  98. /**/
  99. // Expands to a Boost.Parameter-enabled function call operator header. All
  100. // arguments are accessible via args and keywords only.
  101. #define BOOST_PARAMETER_BASIC_FUNCTION_CALL_OPERATOR(result, tag_ns, args) \
  102. BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \
  103. result, operator(), operator, tag_ns \
  104. , BOOST_PARAMETER_AUX_PP_FLATTEN(2, 2, 3, args), 0 \
  105. )
  106. /**/
  107. // Expands to a Boost.Parameter-enabled const-qualified function call
  108. // operator header. All arguments are accessible via args and keywords only.
  109. #define BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR(r, tag_ns, args) \
  110. BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \
  111. r, operator(), operator, tag_ns \
  112. , BOOST_PARAMETER_AUX_PP_FLATTEN(2, 2, 3, args), 1 \
  113. )
  114. /**/
  115. #include <boost/parameter/aux_/preprocessor/impl/function_dispatch_layer.hpp>
  116. // Helper macro for BOOST_PARAMETER_FUNCTION.
  117. #define BOOST_PARAMETER_FUNCTION_AUX(result, name, tag_ns, args) \
  118. BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_ns, args, 0) \
  119. BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name, 0); \
  120. BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, name, args, 0, 0) \
  121. BOOST_PARAMETER_FUNCTION_DISPATCH_LAYER( \
  122. 1, (name, BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args), 0, 0, tag_ns) \
  123. )
  124. /**/
  125. // Expands to a Boost.Parameter-enabled function header. All arguments are
  126. // accessible via args and keywords, as well as by name.
  127. #define BOOST_PARAMETER_FUNCTION(result, name, tag_namespace, args) \
  128. BOOST_PARAMETER_FUNCTION_AUX( \
  129. result, name, tag_namespace \
  130. , BOOST_PARAMETER_AUX_PP_FLATTEN(3, 2, 3, args) \
  131. )
  132. /**/
  133. #include <boost/preprocessor/control/if.hpp>
  134. // Helper macro for BOOST_PARAMETER_MEMBER_FUNCTION
  135. // BOOST_PARAMETER_CONST_MEMBER_FUNCTION,
  136. // BOOST_PARAMETER_FUNCTION_CALL_OPERATOR, and
  137. // BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR.
  138. #define BOOST_PARAMETER_MEMBER_FUNCTION_AUX(r, name, impl, tag_ns, c, args) \
  139. BOOST_PARAMETER_FUNCTION_HEAD(r, impl, tag_ns, args, c) \
  140. BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, impl, args, 1, c) \
  141. BOOST_PARAMETER_FUNCTION_DISPATCH_LAYER( \
  142. 0, ( \
  143. impl \
  144. , BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args) \
  145. , BOOST_PP_IF( \
  146. BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(impl) \
  147. , 0 \
  148. , 1 \
  149. ) \
  150. , c \
  151. , tag_ns \
  152. ) \
  153. )
  154. /**/
  155. // Expands to a Boost.Parameter-enabled member function header. All
  156. // arguments are accessible via args and keywords, as well as by name.
  157. #define BOOST_PARAMETER_MEMBER_FUNCTION(result, name, tag_ns, args) \
  158. BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \
  159. result, name, name, tag_ns, 0 \
  160. , BOOST_PARAMETER_AUX_PP_FLATTEN(3, 2, 3, args) \
  161. )
  162. /**/
  163. // Expands to a Boost.Parameter-enabled const-qualified member function
  164. // header. All arguments are accessible via args and keywords, as well as
  165. // by name.
  166. #define BOOST_PARAMETER_CONST_MEMBER_FUNCTION(result, name, tag_ns, args) \
  167. BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \
  168. result, name, name, tag_ns, 1 \
  169. , BOOST_PARAMETER_AUX_PP_FLATTEN(3, 2, 3, args) \
  170. )
  171. /**/
  172. // Expands to a Boost.Parameter-enabled function call operator header. All
  173. // arguments are accessible via args and keywords, as well as by name.
  174. #define BOOST_PARAMETER_FUNCTION_CALL_OPERATOR(result, tag_ns, args) \
  175. BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \
  176. result, operator(), operator, tag_ns, 0 \
  177. , BOOST_PARAMETER_AUX_PP_FLATTEN(3, 2, 3, args) \
  178. )
  179. /**/
  180. // Expands to a Boost.Parameter-enabled const-qualified function call operator
  181. // header. All arguments are accessible via args and keywords, as well as
  182. // by name.
  183. #define BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR(result, tag_ns, args) \
  184. BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \
  185. result, operator(), operator, tag_ns, 1 \
  186. , BOOST_PARAMETER_AUX_PP_FLATTEN(3, 2, 3, args) \
  187. )
  188. /**/
  189. #endif // include guard