lambda_support.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #ifndef BOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2001-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/aux_/config/lambda.hpp>
  14. #if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
  15. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) /**/
  16. # define BOOST_MPL_AUX_LAMBDA_SUPPORT(i,name,params) /**/
  17. #else
  18. # include <boost/mpl/int_fwd.hpp>
  19. # include <boost/mpl/aux_/yes_no.hpp>
  20. # include <boost/mpl/aux_/na_fwd.hpp>
  21. # include <boost/mpl/aux_/preprocessor/params.hpp>
  22. # include <boost/mpl/aux_/preprocessor/enum.hpp>
  23. # include <boost/mpl/aux_/config/msvc.hpp>
  24. # include <boost/mpl/aux_/config/workaround.hpp>
  25. # include <boost/preprocessor/tuple/to_list.hpp>
  26. # include <boost/preprocessor/list/for_each_i.hpp>
  27. # include <boost/preprocessor/inc.hpp>
  28. # include <boost/preprocessor/cat.hpp>
  29. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC(R,typedef_,i,param) \
  30. typedef_ param BOOST_PP_CAT(arg,BOOST_PP_INC(i)); \
  31. /**/
  32. // agurt, 07/mar/03: restore an old revision for the sake of SGI MIPSpro C++
  33. #if BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
  34. # define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
  35. typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
  36. BOOST_PP_LIST_FOR_EACH_I_R( \
  37. 1 \
  38. , BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
  39. , typedef \
  40. , BOOST_PP_TUPLE_TO_LIST(i,params) \
  41. ) \
  42. struct rebind \
  43. { \
  44. template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
  45. : name< BOOST_MPL_PP_PARAMS(i,U) > \
  46. { \
  47. }; \
  48. }; \
  49. /**/
  50. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
  51. BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
  52. /**/
  53. #elif BOOST_WORKAROUND(__EDG_VERSION__, <= 244) && !defined(BOOST_INTEL_CXX_VERSION)
  54. // agurt, 18/jan/03: old EDG-based compilers actually enforce 11.4 para 9
  55. // (in strict mode), so we have to provide an alternative to the
  56. // MSVC-optimized implementation
  57. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
  58. typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
  59. BOOST_PP_LIST_FOR_EACH_I_R( \
  60. 1 \
  61. , BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
  62. , typedef \
  63. , BOOST_PP_TUPLE_TO_LIST(i,params) \
  64. ) \
  65. struct rebind; \
  66. /**/
  67. # define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
  68. BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
  69. }; \
  70. template< BOOST_MPL_PP_PARAMS(i,typename T) > \
  71. struct name<BOOST_MPL_PP_PARAMS(i,T)>::rebind \
  72. { \
  73. template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
  74. : name< BOOST_MPL_PP_PARAMS(i,U) > \
  75. { \
  76. }; \
  77. /**/
  78. #else // __EDG_VERSION__
  79. namespace boost { namespace mpl { namespace aux {
  80. template< typename T > struct has_rebind_tag;
  81. }}}
  82. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
  83. typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
  84. BOOST_PP_LIST_FOR_EACH_I_R( \
  85. 1 \
  86. , BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
  87. , typedef \
  88. , BOOST_PP_TUPLE_TO_LIST(i,params) \
  89. ) \
  90. friend class BOOST_PP_CAT(name,_rebind); \
  91. typedef BOOST_PP_CAT(name,_rebind) rebind; \
  92. /**/
  93. #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610))
  94. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
  95. template< BOOST_MPL_PP_PARAMS(i,typename T) > \
  96. ::boost::mpl::aux::yes_tag operator|( \
  97. ::boost::mpl::aux::has_rebind_tag<int> \
  98. , name<BOOST_MPL_PP_PARAMS(i,T)>* \
  99. ); \
  100. ::boost::mpl::aux::no_tag operator|( \
  101. ::boost::mpl::aux::has_rebind_tag<int> \
  102. , name< BOOST_MPL_PP_ENUM(i,::boost::mpl::na) >* \
  103. ); \
  104. /**/
  105. #elif !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  106. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
  107. template< BOOST_MPL_PP_PARAMS(i,typename T) > \
  108. ::boost::mpl::aux::yes_tag operator|( \
  109. ::boost::mpl::aux::has_rebind_tag<int> \
  110. , ::boost::mpl::aux::has_rebind_tag< name<BOOST_MPL_PP_PARAMS(i,T)> >* \
  111. ); \
  112. /**/
  113. #else
  114. # define BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) /**/
  115. #endif
  116. # if !defined(BOOST_BORLANDC)
  117. # define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
  118. BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
  119. }; \
  120. BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
  121. class BOOST_PP_CAT(name,_rebind) \
  122. { \
  123. public: \
  124. template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
  125. : name< BOOST_MPL_PP_PARAMS(i,U) > \
  126. { \
  127. }; \
  128. /**/
  129. # else
  130. # define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
  131. BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
  132. }; \
  133. BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
  134. class BOOST_PP_CAT(name,_rebind) \
  135. { \
  136. public: \
  137. template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
  138. { \
  139. typedef typename name< BOOST_MPL_PP_PARAMS(i,U) >::type type; \
  140. }; \
  141. /**/
  142. # endif // BOOST_BORLANDC
  143. #endif // __EDG_VERSION__
  144. #endif // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
  145. #endif // BOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED