as_vector.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef BOOST_PP_IS_ITERATING
  7. #if !defined(FUSION_AS_VECTOR_09222005_0950)
  8. #define FUSION_AS_VECTOR_09222005_0950
  9. #include <boost/preprocessor/iterate.hpp>
  10. #include <boost/preprocessor/repetition/enum_params.hpp>
  11. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  12. #include <boost/preprocessor/repetition/repeat.hpp>
  13. #include <boost/preprocessor/cat.hpp>
  14. #include <boost/preprocessor/inc.hpp>
  15. #include <boost/preprocessor/dec.hpp>
  16. #include <boost/fusion/container/vector/vector.hpp>
  17. #include <boost/fusion/iterator/value_of.hpp>
  18. #include <boost/fusion/iterator/deref.hpp>
  19. #include <boost/fusion/iterator/next.hpp>
  20. namespace boost { namespace fusion { namespace detail
  21. {
  22. BOOST_FUSION_BARRIER_BEGIN
  23. template <int size>
  24. struct as_vector
  25. {
  26. BOOST_STATIC_ASSERT_MSG(
  27. size <= FUSION_MAX_VECTOR_SIZE
  28. , "FUSION_MAX_VECTOR_SIZE limit is too low"
  29. );
  30. };
  31. template <>
  32. struct as_vector<0>
  33. {
  34. template <typename Iterator>
  35. struct apply
  36. {
  37. typedef vector0<> type;
  38. };
  39. template <typename Iterator>
  40. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  41. static typename apply<Iterator>::type
  42. call(Iterator)
  43. {
  44. return vector0<>();
  45. }
  46. };
  47. BOOST_FUSION_BARRIER_END
  48. }}}
  49. #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES)
  50. #include <boost/fusion/container/vector/detail/cpp03/preprocessed/as_vector.hpp>
  51. #else
  52. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  53. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/as_vector" FUSION_MAX_VECTOR_SIZE_STR ".hpp")
  54. #endif
  55. /*=============================================================================
  56. Copyright (c) 2001-2011 Joel de Guzman
  57. Distributed under the Boost Software License, Version 1.0. (See accompanying
  58. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  59. This is an auto-generated file. Do not edit!
  60. ==============================================================================*/
  61. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  62. #pragma wave option(preserve: 1)
  63. #endif
  64. namespace boost { namespace fusion { namespace detail
  65. {
  66. BOOST_FUSION_BARRIER_BEGIN
  67. #define BOOST_FUSION_NEXT_ITERATOR(z, n, data) \
  68. typedef typename fusion::result_of::next<BOOST_PP_CAT(I, n)>::type \
  69. BOOST_PP_CAT(I, BOOST_PP_INC(n));
  70. #define BOOST_FUSION_NEXT_CALL_ITERATOR(z, n, data) \
  71. typename gen::BOOST_PP_CAT(I, BOOST_PP_INC(n)) \
  72. BOOST_PP_CAT(i, BOOST_PP_INC(n)) = fusion::next(BOOST_PP_CAT(i, n));
  73. #define BOOST_FUSION_VALUE_OF_ITERATOR(z, n, data) \
  74. typedef typename fusion::result_of::value_of<BOOST_PP_CAT(I, n)>::type \
  75. BOOST_PP_CAT(T, n);
  76. #define BOOST_PP_FILENAME_1 <boost/fusion/container/vector/detail/cpp03/as_vector.hpp>
  77. #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE)
  78. #include BOOST_PP_ITERATE()
  79. #undef BOOST_FUSION_NEXT_ITERATOR
  80. #undef BOOST_FUSION_NEXT_CALL_ITERATOR
  81. #undef BOOST_FUSION_VALUE_OF_ITERATOR
  82. BOOST_FUSION_BARRIER_END
  83. }}}
  84. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  85. #pragma wave option(output: null)
  86. #endif
  87. #endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES
  88. #endif
  89. #else // defined(BOOST_PP_IS_ITERATING)
  90. ///////////////////////////////////////////////////////////////////////////////
  91. //
  92. // Preprocessor vertical repetition code
  93. //
  94. ///////////////////////////////////////////////////////////////////////////////
  95. #define N BOOST_PP_ITERATION()
  96. template <>
  97. struct as_vector<N>
  98. {
  99. template <typename I0>
  100. struct apply
  101. {
  102. BOOST_PP_REPEAT(N, BOOST_FUSION_NEXT_ITERATOR, _)
  103. BOOST_PP_REPEAT(N, BOOST_FUSION_VALUE_OF_ITERATOR, _)
  104. typedef BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> type;
  105. };
  106. template <typename Iterator>
  107. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  108. static typename apply<Iterator>::type
  109. call(Iterator const& i0)
  110. {
  111. typedef apply<Iterator> gen;
  112. typedef typename gen::type result;
  113. BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_FUSION_NEXT_CALL_ITERATOR, _)
  114. return result(BOOST_PP_ENUM_PARAMS(N, *i));
  115. }
  116. };
  117. #undef N
  118. #endif // defined(BOOST_PP_IS_ITERATING)