deprecated.hpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file deprecated.hpp
  3. /// Definition of the deprecated BOOST_PROTO_DEFINE_FUCTION_TEMPLATE and
  4. /// BOOST_PROTO_DEFINE_VARARG_FUCTION_TEMPLATE macros
  5. //
  6. // Copyright 2008 Eric Niebler. Distributed under the Boost
  7. // Software License, Version 1.0. (See accompanying file
  8. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_PROTO_DETAIL_DEPRECATED_HPP_EAN_11_25_2008
  10. #define BOOST_PROTO_DETAIL_DEPRECATED_HPP_EAN_11_25_2008
  11. #include <boost/preprocessor/cat.hpp>
  12. #include <boost/preprocessor/facilities/intercept.hpp>
  13. #include <boost/preprocessor/arithmetic/inc.hpp>
  14. #include <boost/preprocessor/arithmetic/dec.hpp>
  15. #include <boost/preprocessor/arithmetic/sub.hpp>
  16. #include <boost/preprocessor/punctuation/comma_if.hpp>
  17. #include <boost/preprocessor/control/if.hpp>
  18. #include <boost/preprocessor/control/expr_if.hpp>
  19. #include <boost/preprocessor/comparison/greater.hpp>
  20. #include <boost/preprocessor/tuple/elem.hpp>
  21. #include <boost/preprocessor/tuple/to_list.hpp>
  22. #include <boost/preprocessor/logical/and.hpp>
  23. #include <boost/preprocessor/seq/size.hpp>
  24. #include <boost/preprocessor/seq/enum.hpp>
  25. #include <boost/preprocessor/seq/seq.hpp>
  26. #include <boost/preprocessor/seq/to_tuple.hpp>
  27. #include <boost/preprocessor/seq/for_each_i.hpp>
  28. #include <boost/preprocessor/seq/pop_back.hpp>
  29. #include <boost/preprocessor/seq/push_back.hpp>
  30. #include <boost/preprocessor/seq/push_front.hpp>
  31. #include <boost/preprocessor/list/for_each_i.hpp>
  32. #include <boost/preprocessor/repetition/repeat.hpp>
  33. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  34. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  35. #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
  36. #include <boost/proto/proto_fwd.hpp>
  37. /// INTERNAL ONLY
  38. ///
  39. #define BOOST_PROTO_VARARG_TEMPLATE_AUX_(R, DATA, I, ELEM) \
  40. (ELEM BOOST_PP_CAT(BOOST_PP_CAT(X, DATA), BOOST_PP_CAT(_, I))) \
  41. /**/
  42. /// INTERNAL ONLY
  43. ///
  44. #define BOOST_PROTO_VARARG_TEMPLATE_YES_(R, DATA, I, ELEM) \
  45. BOOST_PP_LIST_FOR_EACH_I_R( \
  46. R \
  47. , BOOST_PROTO_VARARG_TEMPLATE_AUX_ \
  48. , I \
  49. , BOOST_PP_TUPLE_TO_LIST( \
  50. BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
  51. , BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(ELEM)) \
  52. ) \
  53. ) \
  54. /**/
  55. /// INTERNAL ONLY
  56. ///
  57. #define BOOST_PROTO_VARARG_TEMPLATE_NO_(R, DATA, I, ELEM) \
  58. /**/
  59. /// INTERNAL ONLY
  60. ///
  61. #define BOOST_PROTO_VARARG_TEMPLATE_(R, DATA, I, ELEM) \
  62. BOOST_PP_IF( \
  63. BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
  64. , BOOST_PROTO_VARARG_TEMPLATE_YES_ \
  65. , BOOST_PROTO_VARARG_TEMPLATE_NO_ \
  66. )(R, DATA, I, ELEM) \
  67. /**/
  68. /// INTERNAL ONLY
  69. ///
  70. #define BOOST_PROTO_VARARG_TYPE_AUX_(R, DATA, I, ELEM) \
  71. (BOOST_PP_CAT(BOOST_PP_CAT(X, DATA), BOOST_PP_CAT(_, I))) \
  72. /**/
  73. /// INTERNAL ONLY
  74. ///
  75. #define BOOST_PROTO_TEMPLATE_PARAMS_YES_(R, DATA, I, ELEM) \
  76. < \
  77. BOOST_PP_SEQ_ENUM( \
  78. BOOST_PP_LIST_FOR_EACH_I_R( \
  79. R \
  80. , BOOST_PROTO_VARARG_TYPE_AUX_ \
  81. , I \
  82. , BOOST_PP_TUPLE_TO_LIST( \
  83. BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
  84. , BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(ELEM)) \
  85. ) \
  86. ) \
  87. ) \
  88. > \
  89. /**/
  90. /// INTERNAL ONLY
  91. ///
  92. #define BOOST_PROTO_TEMPLATE_PARAMS_NO_(R, DATA, I, ELEM) \
  93. /**/
  94. /// INTERNAL ONLY
  95. ///
  96. #define BOOST_PROTO_VARARG_TYPE_(R, DATA, I, ELEM) \
  97. BOOST_PP_COMMA_IF(I) \
  98. BOOST_PP_SEQ_HEAD(ELEM) \
  99. BOOST_PP_IF( \
  100. BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
  101. , BOOST_PROTO_TEMPLATE_PARAMS_YES_ \
  102. , BOOST_PROTO_TEMPLATE_PARAMS_NO_ \
  103. )(R, DATA, I, ELEM) BOOST_PP_EXPR_IF(BOOST_PP_GREATER(I, 1), const) \
  104. /**/
  105. /// INTERNAL ONLY
  106. ///
  107. #define BOOST_PROTO_VARARG_AS_EXPR_(R, DATA, I, ELEM) \
  108. BOOST_PP_EXPR_IF( \
  109. BOOST_PP_GREATER(I, 1) \
  110. , (( \
  111. BOOST_PP_SEQ_HEAD(ELEM) \
  112. BOOST_PP_IF( \
  113. BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
  114. , BOOST_PROTO_TEMPLATE_PARAMS_YES_ \
  115. , BOOST_PROTO_TEMPLATE_PARAMS_NO_ \
  116. )(R, DATA, I, ELEM)() \
  117. )) \
  118. ) \
  119. /**/
  120. /// INTERNAL ONLY
  121. ///
  122. #define BOOST_PROTO_VARARG_AS_CHILD_(Z, N, DATA) \
  123. (BOOST_PP_CAT(DATA, N)) \
  124. /**/
  125. /// INTERNAL ONLY
  126. ///
  127. #define BOOST_PROTO_SEQ_PUSH_FRONT(SEQ, ELEM) \
  128. BOOST_PP_SEQ_POP_BACK(BOOST_PP_SEQ_PUSH_FRONT(BOOST_PP_SEQ_PUSH_BACK(SEQ, _dummy_), ELEM)) \
  129. /**/
  130. /// INTERNAL ONLY
  131. ///
  132. #define BOOST_PROTO_VARARG_AS_PARAM_(Z, N, DATA) \
  133. (BOOST_PP_CAT(DATA, N)) \
  134. /**/
  135. /// INTERNAL ONLY
  136. ///
  137. #define BOOST_PROTO_VARARG_FUN_(Z, N, DATA) \
  138. template< \
  139. BOOST_PP_SEQ_ENUM( \
  140. BOOST_PP_SEQ_FOR_EACH_I( \
  141. BOOST_PROTO_VARARG_TEMPLATE_, ~ \
  142. , BOOST_PP_SEQ_PUSH_FRONT( \
  143. BOOST_PROTO_SEQ_PUSH_FRONT( \
  144. BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
  145. , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
  146. ) \
  147. , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
  148. ) \
  149. ) \
  150. BOOST_PP_REPEAT_ ## Z(N, BOOST_PROTO_VARARG_AS_PARAM_, typename A) \
  151. ) \
  152. > \
  153. typename boost::proto::result_of::make_expr< \
  154. BOOST_PP_SEQ_FOR_EACH_I( \
  155. BOOST_PROTO_VARARG_TYPE_, ~ \
  156. , BOOST_PP_SEQ_PUSH_FRONT( \
  157. BOOST_PROTO_SEQ_PUSH_FRONT( \
  158. BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
  159. , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
  160. ) \
  161. , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
  162. ) \
  163. ) \
  164. BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
  165. >::type const \
  166. BOOST_PP_TUPLE_ELEM(4, 0, DATA)(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) \
  167. { \
  168. return boost::proto::detail::make_expr_< \
  169. BOOST_PP_SEQ_FOR_EACH_I( \
  170. BOOST_PROTO_VARARG_TYPE_, ~ \
  171. , BOOST_PP_SEQ_PUSH_FRONT( \
  172. BOOST_PROTO_SEQ_PUSH_FRONT( \
  173. BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
  174. , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
  175. ) \
  176. , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
  177. ) \
  178. ) \
  179. BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
  180. >()( \
  181. BOOST_PP_SEQ_ENUM( \
  182. BOOST_PP_SEQ_FOR_EACH_I( \
  183. BOOST_PROTO_VARARG_AS_EXPR_, ~ \
  184. , BOOST_PP_SEQ_PUSH_FRONT( \
  185. BOOST_PROTO_SEQ_PUSH_FRONT( \
  186. BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
  187. , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
  188. ) \
  189. , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
  190. ) \
  191. ) \
  192. BOOST_PP_REPEAT_ ## Z(N, BOOST_PROTO_VARARG_AS_CHILD_, a) \
  193. ) \
  194. ); \
  195. } \
  196. /**/
  197. /// \code
  198. /// BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(
  199. /// 1
  200. /// , construct
  201. /// , boost::proto::default_domain
  202. /// , (boost::proto::tag::function)
  203. /// , ((op::construct)(typename)(int))
  204. /// )
  205. /// \endcode
  206. #define BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(ARGCOUNT, NAME, DOMAIN, TAG, BOUNDARGS) \
  207. BOOST_PP_REPEAT_FROM_TO( \
  208. ARGCOUNT \
  209. , BOOST_PP_INC(ARGCOUNT) \
  210. , BOOST_PROTO_VARARG_FUN_ \
  211. , (NAME, TAG, BOUNDARGS, DOMAIN) \
  212. )\
  213. /**/
  214. /// \code
  215. /// BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(
  216. /// construct
  217. /// , boost::proto::default_domain
  218. /// , (boost::proto::tag::function)
  219. /// , ((op::construct)(typename)(int))
  220. /// )
  221. /// \endcode
  222. #define BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(NAME, DOMAIN, TAG, BOUNDARGS) \
  223. BOOST_PP_REPEAT( \
  224. BOOST_PP_SUB(BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), BOOST_PP_SEQ_SIZE(BOUNDARGS)) \
  225. , BOOST_PROTO_VARARG_FUN_ \
  226. , (NAME, TAG, BOUNDARGS, DOMAIN) \
  227. ) \
  228. /**/
  229. #endif