/Src/Dependencies/Boost/boost/fusion/container/vector/detail/as_vector.hpp

http://hadesmem.googlecode.com/ · C++ Header · 101 lines · 74 code · 16 blank · 11 comment · 0 complexity · 629b36fc05eef56ae5b1c7e7233d94ef MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2006 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. template <int size>
  23. struct as_vector;
  24. template <>
  25. struct as_vector<0>
  26. {
  27. template <typename Iterator>
  28. struct apply
  29. {
  30. typedef vector0<> type;
  31. };
  32. template <typename Iterator>
  33. static typename apply<Iterator>::type
  34. call(Iterator)
  35. {
  36. return vector0<>();
  37. }
  38. };
  39. #define BOOST_FUSION_NEXT_ITERATOR(z, n, data) \
  40. typedef typename fusion::result_of::next<BOOST_PP_CAT(I, n)>::type \
  41. BOOST_PP_CAT(I, BOOST_PP_INC(n));
  42. #define BOOST_FUSION_NEXT_CALL_ITERATOR(z, n, data) \
  43. typename gen::BOOST_PP_CAT(I, BOOST_PP_INC(n)) \
  44. BOOST_PP_CAT(i, BOOST_PP_INC(n)) = fusion::next(BOOST_PP_CAT(i, n));
  45. #define BOOST_FUSION_VALUE_OF_ITERATOR(z, n, data) \
  46. typedef typename fusion::result_of::value_of<BOOST_PP_CAT(I, n)>::type \
  47. BOOST_PP_CAT(T, n);
  48. #define BOOST_PP_FILENAME_1 <boost/fusion/container/vector/detail/as_vector.hpp>
  49. #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE)
  50. #include BOOST_PP_ITERATE()
  51. #undef BOOST_FUSION_NEXT_ITERATOR
  52. #undef BOOST_FUSION_NEXT_CALL_ITERATOR
  53. #undef BOOST_FUSION_VALUE_OF_ITERATOR
  54. }}}
  55. #endif
  56. #else // defined(BOOST_PP_IS_ITERATING)
  57. ///////////////////////////////////////////////////////////////////////////////
  58. //
  59. // Preprocessor vertical repetition code
  60. //
  61. ///////////////////////////////////////////////////////////////////////////////
  62. #define N BOOST_PP_ITERATION()
  63. template <>
  64. struct as_vector<N>
  65. {
  66. template <typename I0>
  67. struct apply
  68. {
  69. BOOST_PP_REPEAT(N, BOOST_FUSION_NEXT_ITERATOR, _)
  70. BOOST_PP_REPEAT(N, BOOST_FUSION_VALUE_OF_ITERATOR, _)
  71. typedef BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> type;
  72. };
  73. template <typename Iterator>
  74. static typename apply<Iterator>::type
  75. call(Iterator const& i0)
  76. {
  77. typedef apply<Iterator> gen;
  78. typedef typename gen::type result;
  79. BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_FUSION_NEXT_CALL_ITERATOR, _)
  80. return result(BOOST_PP_ENUM_PARAMS(N, *i));
  81. }
  82. };
  83. #undef N
  84. #endif // defined(BOOST_PP_IS_ITERATING)