apply_wrap.hpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #if !defined(BOOST_PP_IS_ITERATING)
  2. ///// header body
  3. #ifndef BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
  4. #define BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
  5. // Copyright Aleksey Gurtovoy 2000-2008
  6. //
  7. // Distributed under the Boost Software License, Version 1.0.
  8. // (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // See http://www.boost.org/libs/mpl for documentation.
  12. // $Id$
  13. // $Date$
  14. // $Revision$
  15. #if !defined(BOOST_MPL_PREPROCESSING_MODE)
  16. # include <boost/mpl/aux_/arity.hpp>
  17. # include <boost/mpl/aux_/has_apply.hpp>
  18. # include <boost/mpl/aux_/na.hpp>
  19. # include <boost/mpl/aux_/msvc_never_true.hpp>
  20. #endif
  21. #include <boost/mpl/aux_/config/use_preprocessed.hpp>
  22. #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
  23. && !defined(BOOST_MPL_PREPROCESSING_MODE)
  24. # define BOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp
  25. # include <boost/mpl/aux_/include_preprocessed.hpp>
  26. #else
  27. # include <boost/mpl/limits/arity.hpp>
  28. # include <boost/mpl/aux_/preprocessor/params.hpp>
  29. # include <boost/mpl/aux_/preprocessor/enum.hpp>
  30. # include <boost/mpl/aux_/preprocessor/add.hpp>
  31. # include <boost/mpl/aux_/config/bcc.hpp>
  32. # include <boost/mpl/aux_/config/ctps.hpp>
  33. # include <boost/mpl/aux_/config/dtp.hpp>
  34. # include <boost/mpl/aux_/config/eti.hpp>
  35. # include <boost/mpl/aux_/config/msvc.hpp>
  36. # include <boost/mpl/aux_/config/workaround.hpp>
  37. # include <boost/preprocessor/comma_if.hpp>
  38. # include <boost/preprocessor/logical/and.hpp>
  39. # include <boost/preprocessor/inc.hpp>
  40. # include <boost/preprocessor/iterate.hpp>
  41. namespace boost { namespace mpl {
  42. // local macros, #undef-ined at the end of the header
  43. # define AUX778076_APPLY_WRAP_PARAMS(n, param) \
  44. BOOST_MPL_PP_PARAMS(n, param) \
  45. /**/
  46. # define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \
  47. BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
  48. /**/
  49. #define BOOST_PP_ITERATION_PARAMS_1 \
  50. (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply_wrap.hpp>))
  51. #include BOOST_PP_ITERATE()
  52. # undef AUX778076_APPLY_WRAP_SPEC_PARAMS
  53. # undef AUX778076_APPLY_WRAP_PARAMS
  54. }}
  55. #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  56. #endif // BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
  57. ///// iteration, depth == 1
  58. // For gcc 4.4 compatability, we must include the
  59. // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
  60. #else // BOOST_PP_IS_ITERATING
  61. #if BOOST_PP_ITERATION_DEPTH() == 1
  62. # define i_ BOOST_PP_FRAME_ITERATION(1)
  63. # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  64. // MSVC version
  65. #define AUX778076_MSVC_DTW_NAME BOOST_PP_CAT(msvc_apply,i_)
  66. #define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
  67. #define AUX778076_MSVC_DTW_ARITY i_
  68. #include <boost/mpl/aux_/msvc_dtw.hpp>
  69. template<
  70. typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
  71. >
  72. struct BOOST_PP_CAT(apply_wrap,i_)
  73. {
  74. // Metafunction forwarding confuses vc6
  75. typedef typename BOOST_PP_CAT(msvc_apply,i_)<F>::template result_<
  76. AUX778076_APPLY_WRAP_PARAMS(i_, T)
  77. >::type type;
  78. };
  79. # elif defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
  80. // MWCW/Borland version
  81. template<
  82. int N, typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
  83. >
  84. struct BOOST_PP_CAT(apply_wrap_impl,i_);
  85. #define BOOST_PP_ITERATION_PARAMS_2 \
  86. (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <boost/mpl/apply_wrap.hpp>))
  87. #include BOOST_PP_ITERATE()
  88. template<
  89. typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
  90. >
  91. struct BOOST_PP_CAT(apply_wrap,i_)
  92. : BOOST_PP_CAT(apply_wrap_impl,i_)<
  93. ::boost::mpl::aux::arity<F,i_>::value
  94. , F
  95. BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
  96. >::type
  97. {
  98. };
  99. # else
  100. // ISO98 C++, with minor concession to vc7
  101. template<
  102. typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
  103. #if i_ == 0
  104. , typename has_apply_ = typename aux::has_apply<F>::type
  105. #endif
  106. >
  107. struct BOOST_PP_CAT(apply_wrap,i_)
  108. // metafunction forwarding confuses MSVC 7.0
  109. #if !BOOST_WORKAROUND(BOOST_MSVC, == 1300)
  110. : F::template apply< AUX778076_APPLY_WRAP_PARAMS(i_, T) >
  111. {
  112. #else
  113. {
  114. typedef typename F::template apply<
  115. AUX778076_APPLY_WRAP_PARAMS(i_, T)
  116. >::type type;
  117. #endif
  118. };
  119. #if i_ == 0 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  120. template< typename F >
  121. struct BOOST_PP_CAT(apply_wrap,i_)<F,true_>
  122. : F::apply
  123. {
  124. };
  125. #endif
  126. # endif // workarounds
  127. #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
  128. /// workaround for ETI bug
  129. template<>
  130. struct BOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)>
  131. {
  132. typedef int type;
  133. };
  134. #endif
  135. # undef i_
  136. ///// iteration, depth == 2
  137. #elif BOOST_PP_ITERATION_DEPTH() == 2
  138. # define j_ BOOST_PP_FRAME_ITERATION(2)
  139. #if i_ == 0 && j_ == 0 \
  140. && defined(BOOST_MPL_CFG_BCC590_WORKAROUNDS) \
  141. && !defined(BOOST_MPL_CFG_NO_HAS_APPLY)
  142. template< typename F, bool F_has_apply >
  143. struct apply_wrap_impl0_bcb {
  144. typedef typename F::template apply< na > type;
  145. };
  146. template< typename F >
  147. struct apply_wrap_impl0_bcb< F, true > {
  148. typedef typename F::apply type;
  149. };
  150. template<
  151. typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
  152. >
  153. struct BOOST_PP_CAT(apply_wrap_impl,i_)<
  154. BOOST_MPL_PP_ADD(i_, j_)
  155. , F
  156. BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
  157. >
  158. {
  159. typedef apply_wrap_impl0_bcb< F, aux::has_apply< F >::value >::type type;
  160. };
  161. #else
  162. template<
  163. typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
  164. >
  165. struct BOOST_PP_CAT(apply_wrap_impl,i_)<
  166. BOOST_MPL_PP_ADD(i_, j_)
  167. , F
  168. BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
  169. >
  170. {
  171. typedef typename F::template apply<
  172. AUX778076_APPLY_WRAP_PARAMS(i_, T)
  173. #if i_ == 0 && j_ == 0
  174. /// since the defaults are "lost", we have to pass *something* even for nullary
  175. /// metafunction classes
  176. na
  177. #else
  178. BOOST_PP_COMMA_IF(BOOST_PP_AND(i_, j_)) BOOST_MPL_PP_ENUM(j_, na)
  179. #endif
  180. > type;
  181. };
  182. #endif
  183. # undef j_
  184. #endif // BOOST_PP_ITERATION_DEPTH()
  185. #endif // BOOST_PP_IS_ITERATING