na_spec.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #ifndef BOOST_MPL_AUX_NA_SPEC_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_NA_SPEC_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. #if !defined(BOOST_MPL_PREPROCESSING_MODE)
  14. # include <boost/mpl/lambda_fwd.hpp>
  15. # include <boost/mpl/int.hpp>
  16. # include <boost/mpl/bool.hpp>
  17. # include <boost/mpl/aux_/na.hpp>
  18. # include <boost/mpl/aux_/arity.hpp>
  19. # include <boost/mpl/aux_/template_arity_fwd.hpp>
  20. #endif
  21. #include <boost/mpl/aux_/preprocessor/params.hpp>
  22. #include <boost/mpl/aux_/preprocessor/enum.hpp>
  23. #include <boost/mpl/aux_/preprocessor/def_params_tail.hpp>
  24. #include <boost/mpl/aux_/lambda_arity_param.hpp>
  25. #include <boost/mpl/aux_/config/dtp.hpp>
  26. #include <boost/mpl/aux_/config/eti.hpp>
  27. #include <boost/mpl/aux_/nttp_decl.hpp>
  28. #include <boost/mpl/aux_/config/ttp.hpp>
  29. #include <boost/mpl/aux_/config/lambda.hpp>
  30. #include <boost/mpl/aux_/config/overload_resolution.hpp>
  31. #define BOOST_MPL_AUX_NA_PARAMS(i) \
  32. BOOST_MPL_PP_ENUM(i, na) \
  33. /**/
  34. #if defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
  35. # define BOOST_MPL_AUX_NA_SPEC_ARITY(i, name) \
  36. namespace aux { \
  37. template< BOOST_MPL_AUX_NTTP_DECL(int, N) > \
  38. struct arity< \
  39. name< BOOST_MPL_AUX_NA_PARAMS(i) > \
  40. , N \
  41. > \
  42. : int_< BOOST_MPL_LIMIT_METAFUNCTION_ARITY > \
  43. { \
  44. }; \
  45. } \
  46. /**/
  47. #else
  48. # define BOOST_MPL_AUX_NA_SPEC_ARITY(i, name) /**/
  49. #endif
  50. #define BOOST_MPL_AUX_NA_SPEC_MAIN(i, name) \
  51. template<> \
  52. struct name< BOOST_MPL_AUX_NA_PARAMS(i) > \
  53. { \
  54. template< \
  55. BOOST_MPL_PP_PARAMS(i, typename T) \
  56. BOOST_MPL_PP_NESTED_DEF_PARAMS_TAIL(i, typename T, na) \
  57. > \
  58. struct apply \
  59. : name< BOOST_MPL_PP_PARAMS(i, T) > \
  60. { \
  61. }; \
  62. }; \
  63. /**/
  64. #if defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
  65. # define BOOST_MPL_AUX_NA_SPEC_LAMBDA(i, name) \
  66. template<> \
  67. struct lambda< \
  68. name< BOOST_MPL_AUX_NA_PARAMS(i) > \
  69. , void_ \
  70. , true_ \
  71. > \
  72. { \
  73. typedef false_ is_le; \
  74. typedef name< BOOST_MPL_AUX_NA_PARAMS(i) > type; \
  75. }; \
  76. template<> \
  77. struct lambda< \
  78. name< BOOST_MPL_AUX_NA_PARAMS(i) > \
  79. , void_ \
  80. , false_ \
  81. > \
  82. { \
  83. typedef false_ is_le; \
  84. typedef name< BOOST_MPL_AUX_NA_PARAMS(i) > type; \
  85. }; \
  86. /**/
  87. #else
  88. # define BOOST_MPL_AUX_NA_SPEC_LAMBDA(i, name) \
  89. template< typename Tag > \
  90. struct lambda< \
  91. name< BOOST_MPL_AUX_NA_PARAMS(i) > \
  92. , Tag \
  93. BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(int_<-1>) \
  94. > \
  95. { \
  96. typedef false_ is_le; \
  97. typedef name< BOOST_MPL_AUX_NA_PARAMS(i) > result_; \
  98. typedef name< BOOST_MPL_AUX_NA_PARAMS(i) > type; \
  99. }; \
  100. /**/
  101. #endif
  102. #if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING) \
  103. || defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT) \
  104. && defined(BOOST_MPL_CFG_BROKEN_OVERLOAD_RESOLUTION)
  105. # define BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(i, j, name) \
  106. namespace aux { \
  107. template< BOOST_MPL_PP_PARAMS(j, typename T) > \
  108. struct template_arity< \
  109. name< BOOST_MPL_PP_PARAMS(j, T) > \
  110. > \
  111. : int_<j> \
  112. { \
  113. }; \
  114. \
  115. template<> \
  116. struct template_arity< \
  117. name< BOOST_MPL_PP_ENUM(i, na) > \
  118. > \
  119. : int_<-1> \
  120. { \
  121. }; \
  122. } \
  123. /**/
  124. #else
  125. # define BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(i, j, name) /**/
  126. #endif
  127. #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
  128. # define BOOST_MPL_AUX_NA_SPEC_ETI(i, name) \
  129. template<> \
  130. struct name< BOOST_MPL_PP_ENUM(i, int) > \
  131. { \
  132. typedef int type; \
  133. enum { value = 0 }; \
  134. }; \
  135. /**/
  136. #else
  137. # define BOOST_MPL_AUX_NA_SPEC_ETI(i, name) /**/
  138. #endif
  139. #define BOOST_MPL_AUX_NA_PARAM(param) param = na
  140. #define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \
  141. BOOST_MPL_AUX_NA_SPEC_MAIN(i, name) \
  142. BOOST_MPL_AUX_NA_SPEC_LAMBDA(i, name) \
  143. BOOST_MPL_AUX_NA_SPEC_ARITY(i, name) \
  144. BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(i, i, name) \
  145. /**/
  146. #define BOOST_MPL_AUX_NA_SPEC(i, name) \
  147. BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \
  148. BOOST_MPL_AUX_NA_SPEC_ETI(i, name) \
  149. /**/
  150. #define BOOST_MPL_AUX_NA_SPEC2(i, j, name) \
  151. BOOST_MPL_AUX_NA_SPEC_MAIN(i, name) \
  152. BOOST_MPL_AUX_NA_SPEC_ETI(i, name) \
  153. BOOST_MPL_AUX_NA_SPEC_LAMBDA(i, name) \
  154. BOOST_MPL_AUX_NA_SPEC_ARITY(i, name) \
  155. BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(i, j, name) \
  156. /**/
  157. #endif // BOOST_MPL_AUX_NA_SPEC_HPP_INCLUDED