logical_op.hpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // Copyright Aleksey Gurtovoy 2000-2004
  2. //
  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. //
  7. // See http://www.boost.org/libs/mpl for documentation.
  8. // $Id$
  9. // $Date$
  10. // $Revision$
  11. // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION!
  12. #if !defined(BOOST_MPL_PREPROCESSING_MODE)
  13. # include <boost/mpl/bool.hpp>
  14. # include <boost/mpl/aux_/nested_type_wknd.hpp>
  15. # include <boost/mpl/aux_/na_spec.hpp>
  16. # include <boost/mpl/aux_/lambda_support.hpp>
  17. #endif
  18. #include <boost/mpl/limits/arity.hpp>
  19. #include <boost/mpl/aux_/preprocessor/params.hpp>
  20. #include <boost/mpl/aux_/preprocessor/ext_params.hpp>
  21. #include <boost/mpl/aux_/preprocessor/def_params_tail.hpp>
  22. #include <boost/mpl/aux_/preprocessor/enum.hpp>
  23. #include <boost/mpl/aux_/preprocessor/sub.hpp>
  24. #include <boost/mpl/aux_/config/ctps.hpp>
  25. #include <boost/mpl/aux_/config/workaround.hpp>
  26. #include <boost/preprocessor/dec.hpp>
  27. #include <boost/preprocessor/inc.hpp>
  28. #include <boost/preprocessor/cat.hpp>
  29. namespace boost { namespace mpl {
  30. # define AUX778076_PARAMS(param, sub) \
  31. BOOST_MPL_PP_PARAMS( \
  32. BOOST_MPL_PP_SUB(BOOST_MPL_LIMIT_METAFUNCTION_ARITY, sub) \
  33. , param \
  34. ) \
  35. /**/
  36. # define AUX778076_SHIFTED_PARAMS(param, sub) \
  37. BOOST_MPL_PP_EXT_PARAMS( \
  38. 2, BOOST_MPL_PP_SUB(BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY), sub) \
  39. , param \
  40. ) \
  41. /**/
  42. # define AUX778076_SPEC_PARAMS(param) \
  43. BOOST_MPL_PP_ENUM( \
  44. BOOST_PP_DEC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY) \
  45. , param \
  46. ) \
  47. /**/
  48. namespace aux {
  49. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  50. template< bool C_, AUX778076_PARAMS(typename T, 1) >
  51. struct BOOST_PP_CAT(AUX778076_OP_NAME,impl)
  52. : BOOST_PP_CAT(AUX778076_OP_VALUE1,_)
  53. {
  54. };
  55. template< AUX778076_PARAMS(typename T, 1) >
  56. struct BOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUX778076_OP_VALUE2,AUX778076_PARAMS(T, 1) >
  57. : BOOST_PP_CAT(AUX778076_OP_NAME,impl)<
  58. BOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
  59. , AUX778076_SHIFTED_PARAMS(T, 1)
  60. , BOOST_PP_CAT(AUX778076_OP_VALUE2,_)
  61. >
  62. {
  63. };
  64. template<>
  65. struct BOOST_PP_CAT(AUX778076_OP_NAME,impl)<
  66. AUX778076_OP_VALUE2
  67. , AUX778076_SPEC_PARAMS(BOOST_PP_CAT(AUX778076_OP_VALUE2,_))
  68. >
  69. : BOOST_PP_CAT(AUX778076_OP_VALUE2,_)
  70. {
  71. };
  72. #else
  73. template< bool C_ > struct BOOST_PP_CAT(AUX778076_OP_NAME,impl)
  74. {
  75. template< AUX778076_PARAMS(typename T, 1) > struct result_
  76. : BOOST_PP_CAT(AUX778076_OP_VALUE1,_)
  77. {
  78. };
  79. };
  80. template<> struct BOOST_PP_CAT(AUX778076_OP_NAME,impl)<AUX778076_OP_VALUE2>
  81. {
  82. template< AUX778076_PARAMS(typename T, 1) > struct result_
  83. : BOOST_PP_CAT(AUX778076_OP_NAME,impl)<
  84. BOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
  85. >::template result_< AUX778076_SHIFTED_PARAMS(T,1),BOOST_PP_CAT(AUX778076_OP_VALUE2,_) >
  86. {
  87. };
  88. #if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
  89. template<> struct result_<AUX778076_SPEC_PARAMS(BOOST_PP_CAT(AUX778076_OP_VALUE2,_))>
  90. : BOOST_PP_CAT(AUX778076_OP_VALUE2,_)
  91. {
  92. };
  93. };
  94. #else
  95. };
  96. template<>
  97. struct BOOST_PP_CAT(AUX778076_OP_NAME,impl)<AUX778076_OP_VALUE2>
  98. ::result_< AUX778076_SPEC_PARAMS(BOOST_PP_CAT(AUX778076_OP_VALUE2,_)) >
  99. : BOOST_PP_CAT(AUX778076_OP_VALUE2,_)
  100. {
  101. };
  102. #endif // BOOST_MSVC == 1300
  103. #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  104. } // namespace aux
  105. template<
  106. typename BOOST_MPL_AUX_NA_PARAM(T1)
  107. , typename BOOST_MPL_AUX_NA_PARAM(T2)
  108. BOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename T, BOOST_PP_CAT(AUX778076_OP_VALUE2,_))
  109. >
  110. struct AUX778076_OP_NAME
  111. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  112. : aux::BOOST_PP_CAT(AUX778076_OP_NAME,impl)<
  113. BOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
  114. , AUX778076_SHIFTED_PARAMS(T,0)
  115. >
  116. #else
  117. : aux::BOOST_PP_CAT(AUX778076_OP_NAME,impl)<
  118. BOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
  119. >::template result_< AUX778076_SHIFTED_PARAMS(T,0) >
  120. #endif
  121. {
  122. BOOST_MPL_AUX_LAMBDA_SUPPORT(
  123. BOOST_MPL_LIMIT_METAFUNCTION_ARITY
  124. , AUX778076_OP_NAME
  125. , (AUX778076_PARAMS(T, 0))
  126. )
  127. };
  128. BOOST_MPL_AUX_NA_SPEC2(
  129. 2
  130. , BOOST_MPL_LIMIT_METAFUNCTION_ARITY
  131. , AUX778076_OP_NAME
  132. )
  133. }}
  134. #undef AUX778076_SPEC_PARAMS
  135. #undef AUX778076_SHIFTED_PARAMS
  136. #undef AUX778076_PARAMS
  137. #undef AUX778076_OP_NAME
  138. #undef AUX778076_OP_VALUE1
  139. #undef AUX778076_OP_VALUE2