unpack_args.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #if !defined(BOOST_PP_IS_ITERATING)
  2. ///// header body
  3. #ifndef BOOST_MPL_UNPACK_ARGS_HPP_INCLUDED
  4. #define BOOST_MPL_UNPACK_ARGS_HPP_INCLUDED
  5. // Copyright Aleksey Gurtovoy 2002-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/apply.hpp>
  17. # include <boost/mpl/at.hpp>
  18. # include <boost/mpl/size.hpp>
  19. # include <boost/mpl/aux_/nttp_decl.hpp>
  20. # include <boost/mpl/aux_/lambda_spec.hpp>
  21. #endif
  22. #include <boost/mpl/aux_/config/use_preprocessed.hpp>
  23. #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
  24. && !defined(BOOST_MPL_PREPROCESSING_MODE)
  25. # define BOOST_MPL_PREPROCESSED_HEADER unpack_args.hpp
  26. # include <boost/mpl/aux_/include_preprocessed.hpp>
  27. #else
  28. # include <boost/mpl/limits/arity.hpp>
  29. # include <boost/mpl/aux_/preprocessor/repeat.hpp>
  30. # include <boost/mpl/aux_/config/ctps.hpp>
  31. # include <boost/mpl/aux_/config/forwarding.hpp>
  32. # include <boost/preprocessor/iterate.hpp>
  33. # include <boost/preprocessor/cat.hpp>
  34. namespace boost { namespace mpl {
  35. // local macros, #undef-ined at the end of the header
  36. # define AUX778076_UNPACK(unused, i, Args) \
  37. , typename at_c<Args,i>::type \
  38. /**/
  39. # define AUX778076_UNPACKED_ARGS(n, Args) \
  40. BOOST_MPL_PP_REPEAT(n, AUX778076_UNPACK, Args) \
  41. /**/
  42. namespace aux {
  43. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  44. template< int size, typename F, typename Args >
  45. struct unpack_args_impl;
  46. #else
  47. template< BOOST_MPL_AUX_NTTP_DECL(int, size) > struct unpack_args_impl
  48. {
  49. template< typename F, typename Args > struct apply;
  50. };
  51. #endif
  52. #define BOOST_PP_ITERATION_PARAMS_1 \
  53. (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/unpack_args.hpp>))
  54. #include BOOST_PP_ITERATE()
  55. }
  56. template<
  57. typename F
  58. >
  59. struct unpack_args
  60. {
  61. template< typename Args > struct apply
  62. #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
  63. # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  64. : aux::unpack_args_impl< size<Args>::value,F,Args >
  65. # else
  66. : aux::unpack_args_impl< size<Args>::value >
  67. ::template apply< F,Args >
  68. # endif
  69. {
  70. #else // BOOST_MPL_CFG_NO_NESTED_FORWARDING
  71. {
  72. typedef typename aux::unpack_args_impl<
  73. size<Args>::value
  74. , F
  75. , Args
  76. >::type type;
  77. #endif
  78. };
  79. };
  80. BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(1, unpack_args)
  81. # undef AUX778076_UNPACK
  82. # undef AUX778076_UNPACKED_ARGS
  83. }}
  84. #endif // BOOST_MPL_CFG_USE_PREPROCESSED_HEADERS
  85. #endif // BOOST_MPL_UNPACK_ARGS_HPP_INCLUDED
  86. ///// iteration, depth == 1
  87. // For gcc 4.4 compatability, we must include the
  88. // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
  89. #else // BOOST_PP_IS_ITERATING
  90. #if BOOST_PP_ITERATION_DEPTH() == 1
  91. # define i_ BOOST_PP_FRAME_ITERATION(1)
  92. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  93. template< typename F, typename Args >
  94. struct unpack_args_impl<i_,F,Args>
  95. : BOOST_PP_CAT(apply,i_)<
  96. F
  97. AUX778076_UNPACKED_ARGS(i_, Args)
  98. >
  99. {
  100. };
  101. #else
  102. template<> struct unpack_args_impl<i_>
  103. {
  104. template< typename F, typename Args > struct apply
  105. : BOOST_PP_CAT(apply,i_)<
  106. F
  107. AUX778076_UNPACKED_ARGS(i_, Args)
  108. >
  109. {
  110. };
  111. };
  112. #endif
  113. # undef i_
  114. #endif // BOOST_PP_ITERATION_DEPTH()
  115. #endif // BOOST_PP_IS_ITERATING