arg.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #if !defined(BOOST_PP_IS_ITERATING)
  2. ///// header body
  3. #ifndef BOOST_MPL_ARG_HPP_INCLUDED
  4. #define BOOST_MPL_ARG_HPP_INCLUDED
  5. // Copyright Peter Dimov 2001-2002
  6. // Copyright Aleksey Gurtovoy 2001-2004
  7. //
  8. // Distributed under the Boost Software License, Version 1.0.
  9. // (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. //
  12. // See http://www.boost.org/libs/mpl for documentation.
  13. // $Id$
  14. // $Date$
  15. // $Revision$
  16. #if !defined(BOOST_MPL_PREPROCESSING_MODE)
  17. # include <boost/mpl/arg_fwd.hpp>
  18. # include <boost/mpl/aux_/na.hpp>
  19. # include <boost/mpl/aux_/na_assert.hpp>
  20. # include <boost/mpl/aux_/arity_spec.hpp>
  21. # include <boost/mpl/aux_/arg_typedef.hpp>
  22. #endif
  23. #include <boost/mpl/aux_/config/static_constant.hpp>
  24. #include <boost/mpl/aux_/config/use_preprocessed.hpp>
  25. #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
  26. && !defined(BOOST_MPL_PREPROCESSING_MODE)
  27. # define BOOST_MPL_PREPROCESSED_HEADER arg.hpp
  28. # include <boost/mpl/aux_/include_preprocessed.hpp>
  29. #else
  30. # include <boost/mpl/limits/arity.hpp>
  31. # include <boost/mpl/aux_/preprocessor/default_params.hpp>
  32. # include <boost/mpl/aux_/preprocessor/params.hpp>
  33. # include <boost/mpl/aux_/config/lambda.hpp>
  34. # include <boost/mpl/aux_/config/dtp.hpp>
  35. # include <boost/mpl/aux_/nttp_decl.hpp>
  36. # include <boost/preprocessor/iterate.hpp>
  37. # include <boost/preprocessor/inc.hpp>
  38. # include <boost/preprocessor/cat.hpp>
  39. BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN
  40. // local macro, #undef-ined at the end of the header
  41. #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
  42. # define AUX778076_ARG_N_DEFAULT_PARAMS(param,value) \
  43. BOOST_MPL_PP_DEFAULT_PARAMS( \
  44. BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
  45. , param \
  46. , value \
  47. ) \
  48. /**/
  49. #else
  50. # define AUX778076_ARG_N_DEFAULT_PARAMS(param,value) \
  51. BOOST_MPL_PP_PARAMS( \
  52. BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
  53. , param \
  54. ) \
  55. /**/
  56. #endif
  57. #define BOOST_PP_ITERATION_PARAMS_1 \
  58. (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/arg.hpp>))
  59. #include BOOST_PP_ITERATE()
  60. # undef AUX778076_ARG_N_DEFAULT_PARAMS
  61. BOOST_MPL_AUX_NONTYPE_ARITY_SPEC(1,int,arg)
  62. BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE
  63. #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  64. #endif // BOOST_MPL_ARG_HPP_INCLUDED
  65. ///// iteration
  66. #else
  67. #define i_ BOOST_PP_FRAME_ITERATION(1)
  68. #if i_ > 0
  69. template<> struct arg<i_>
  70. {
  71. BOOST_STATIC_CONSTANT(int, value = i_);
  72. typedef arg<BOOST_PP_INC(i_)> next;
  73. BOOST_MPL_AUX_ARG_TYPEDEF(na, tag)
  74. BOOST_MPL_AUX_ARG_TYPEDEF(na, type)
  75. template<
  76. AUX778076_ARG_N_DEFAULT_PARAMS(typename U, na)
  77. >
  78. struct apply
  79. {
  80. typedef BOOST_PP_CAT(U,i_) type;
  81. BOOST_MPL_AUX_ASSERT_NOT_NA(type);
  82. };
  83. };
  84. #else
  85. template<> struct arg<-1>
  86. {
  87. BOOST_STATIC_CONSTANT(int, value = -1);
  88. BOOST_MPL_AUX_ARG_TYPEDEF(na, tag)
  89. BOOST_MPL_AUX_ARG_TYPEDEF(na, type)
  90. template<
  91. AUX778076_ARG_N_DEFAULT_PARAMS(typename U, na)
  92. >
  93. struct apply
  94. {
  95. typedef U1 type;
  96. BOOST_MPL_AUX_ASSERT_NOT_NA(type);
  97. };
  98. };
  99. #endif // i_ > 0
  100. #undef i_
  101. #endif // BOOST_PP_IS_ITERATING