lambda_no_ctps.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #if !defined(BOOST_PP_IS_ITERATING)
  2. ///// header body
  3. #ifndef BOOST_MPL_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
  4. #define BOOST_MPL_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
  5. // Copyright Aleksey Gurtovoy 2000-2004
  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/lambda_fwd.hpp>
  17. # include <boost/mpl/bind_fwd.hpp>
  18. # include <boost/mpl/protect.hpp>
  19. # include <boost/mpl/is_placeholder.hpp>
  20. # include <boost/mpl/if.hpp>
  21. # include <boost/mpl/identity.hpp>
  22. # include <boost/mpl/bool.hpp>
  23. # include <boost/mpl/aux_/na_spec.hpp>
  24. # include <boost/mpl/aux_/lambda_support.hpp>
  25. # include <boost/mpl/aux_/template_arity.hpp>
  26. # include <boost/mpl/aux_/value_wknd.hpp>
  27. #endif
  28. #include <boost/mpl/aux_/config/use_preprocessed.hpp>
  29. #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
  30. && !defined(BOOST_MPL_PREPROCESSING_MODE)
  31. # define BOOST_MPL_PREPROCESSED_HEADER lambda_no_ctps.hpp
  32. # include <boost/mpl/aux_/include_preprocessed.hpp>
  33. #else
  34. # include <boost/mpl/limits/arity.hpp>
  35. # include <boost/mpl/aux_/preprocessor/params.hpp>
  36. # include <boost/mpl/aux_/preprocessor/default_params.hpp>
  37. # include <boost/mpl/aux_/preprocessor/repeat.hpp>
  38. # include <boost/mpl/aux_/preprocessor/enum.hpp>
  39. # include <boost/mpl/aux_/config/msvc.hpp>
  40. # include <boost/mpl/aux_/config/workaround.hpp>
  41. # include <boost/preprocessor/comma_if.hpp>
  42. # include <boost/preprocessor/iterate.hpp>
  43. # include <boost/preprocessor/inc.hpp>
  44. # include <boost/preprocessor/cat.hpp>
  45. namespace boost { namespace mpl {
  46. # define AUX778076_LAMBDA_PARAMS(i_, param) \
  47. BOOST_MPL_PP_PARAMS(i_, param) \
  48. /**/
  49. namespace aux {
  50. #define n_ BOOST_MPL_LIMIT_METAFUNCTION_ARITY
  51. template<
  52. BOOST_MPL_PP_DEFAULT_PARAMS(n_,bool C,false)
  53. >
  54. struct lambda_or
  55. : true_
  56. {
  57. };
  58. template<>
  59. struct lambda_or< BOOST_MPL_PP_ENUM(n_,false) >
  60. : false_
  61. {
  62. };
  63. #undef n_
  64. template< typename Arity > struct lambda_impl
  65. {
  66. template< typename T, typename Tag, typename Protect > struct result_
  67. {
  68. typedef T type;
  69. typedef is_placeholder<T> is_le;
  70. };
  71. };
  72. #define BOOST_PP_ITERATION_PARAMS_1 \
  73. (3,(1, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/aux_/lambda_no_ctps.hpp>))
  74. #include BOOST_PP_ITERATE()
  75. } // namespace aux
  76. template<
  77. typename T
  78. , typename Tag
  79. , typename Protect
  80. >
  81. struct lambda
  82. {
  83. /// Metafunction forwarding confuses MSVC 6.x
  84. typedef typename aux::template_arity<T>::type arity_;
  85. typedef typename aux::lambda_impl<arity_>
  86. ::template result_< T,Tag,Protect > l_;
  87. typedef typename l_::type type;
  88. typedef typename l_::is_le is_le;
  89. BOOST_MPL_AUX_LAMBDA_SUPPORT(3, lambda, (T, Tag, Protect))
  90. };
  91. BOOST_MPL_AUX_NA_SPEC2(1, 3, lambda)
  92. template<
  93. typename T
  94. >
  95. struct is_lambda_expression
  96. : lambda<T>::is_le
  97. {
  98. };
  99. # undef AUX778076_LAMBDA_PARAMS
  100. }}
  101. #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  102. #endif // BOOST_MPL_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
  103. ///// iteration, depth == 1
  104. #else
  105. #define i_ BOOST_PP_FRAME_ITERATION(1)
  106. # define AUX778076_LAMBDA_TYPEDEF(unused, i_, F) \
  107. typedef lambda< \
  108. typename F::BOOST_PP_CAT(arg,BOOST_PP_INC(i_)) \
  109. , Tag \
  110. , false_ \
  111. > BOOST_PP_CAT(l,BOOST_PP_INC(i_)); \
  112. /**/
  113. # define AUX778076_IS_LE_TYPEDEF(unused, i_, unused2) \
  114. typedef typename BOOST_PP_CAT(l,BOOST_PP_INC(i_))::is_le \
  115. BOOST_PP_CAT(is_le,BOOST_PP_INC(i_)); \
  116. /**/
  117. # define AUX778076_IS_LAMBDA_EXPR(unused, i_, unused2) \
  118. BOOST_PP_COMMA_IF(i_) \
  119. BOOST_MPL_AUX_MSVC_VALUE_WKND(BOOST_PP_CAT(is_le,BOOST_PP_INC(i_)))::value \
  120. /**/
  121. # define AUX778076_LAMBDA_RESULT(unused, i_, unused2) \
  122. , typename BOOST_PP_CAT(l,BOOST_PP_INC(i_))::type \
  123. /**/
  124. template<> struct lambda_impl< int_<i_> >
  125. {
  126. template< typename F, typename Tag, typename Protect > struct result_
  127. {
  128. BOOST_MPL_PP_REPEAT(i_, AUX778076_LAMBDA_TYPEDEF, F)
  129. BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LE_TYPEDEF, unused)
  130. typedef aux::lambda_or<
  131. BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LAMBDA_EXPR, unused)
  132. > is_le;
  133. typedef BOOST_PP_CAT(bind,i_)<
  134. typename F::rebind
  135. BOOST_MPL_PP_REPEAT(i_, AUX778076_LAMBDA_RESULT, unused)
  136. > bind_;
  137. typedef typename if_<
  138. is_le
  139. , if_< Protect, mpl::protect<bind_>, bind_ >
  140. , identity<F>
  141. >::type type_;
  142. typedef typename type_::type type;
  143. };
  144. };
  145. # undef AUX778076_LAMBDA_RESULT
  146. # undef AUX778076_IS_LAMBDA_EXPR
  147. # undef AUX778076_IS_LE_TYPEDEF
  148. # undef AUX778076_LAMBDA_TYPEDEF
  149. #undef i_
  150. #endif // BOOST_PP_IS_ITERATING