vector.hpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. #if !defined(FUSION_VECTOR_07072005_1244)
  7. #define FUSION_VECTOR_07072005_1244
  8. #include <boost/fusion/container/vector/vector_fwd.hpp>
  9. #include <boost/fusion/container/vector/detail/vector_n_chooser.hpp>
  10. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  11. #include <boost/mpl/at.hpp>
  12. #include <boost/mpl/bool.hpp>
  13. #include <boost/type_traits/add_reference.hpp>
  14. #include <boost/type_traits/add_const.hpp>
  15. #include <boost/type_traits/is_base_of.hpp>
  16. #include <boost/detail/workaround.hpp>
  17. #if !defined(__WAVE__)
  18. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1600)
  19. #define BOOST_FUSION_VECTOR_COPY_INIT() \
  20. ctor_helper(rhs, is_base_of<vector, Sequence>()) \
  21. #define BOOST_FUSION_VECTOR_CTOR_HELPER() \
  22. static vector_n const& \
  23. ctor_helper(vector const& rhs, mpl::true_) \
  24. { \
  25. return rhs.vec; \
  26. } \
  27. \
  28. template <typename T> \
  29. static T const& \
  30. ctor_helper(T const& rhs, mpl::false_) \
  31. { \
  32. return rhs; \
  33. }
  34. #else
  35. #define BOOST_FUSION_VECTOR_COPY_INIT() \
  36. rhs \
  37. #define BOOST_FUSION_VECTOR_CTOR_HELPER()
  38. #endif
  39. #endif // !defined(__WAVE__)
  40. #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES)
  41. #include <boost/fusion/container/vector/detail/preprocessed/vector.hpp>
  42. #else
  43. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  44. #pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/vvector" FUSION_MAX_VECTOR_SIZE_STR ".hpp")
  45. #endif
  46. /*=============================================================================
  47. Copyright (c) 2001-2011 Joel de Guzman
  48. Distributed under the Boost Software License, Version 1.0. (See accompanying
  49. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  50. This is an auto-generated file. Do not edit!
  51. ==============================================================================*/
  52. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  53. #pragma wave option(preserve: 1)
  54. #endif
  55. namespace boost { namespace fusion
  56. {
  57. struct void_;
  58. struct fusion_sequence_tag;
  59. template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
  60. struct vector
  61. : sequence_base<vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)> >
  62. {
  63. private:
  64. typedef typename detail::vector_n_chooser<
  65. BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>::type
  66. vector_n;
  67. template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
  68. friend struct vector;
  69. public:
  70. typedef typename vector_n::types types;
  71. typedef typename vector_n::fusion_tag fusion_tag;
  72. typedef typename vector_n::tag tag;
  73. typedef typename vector_n::size size;
  74. typedef typename vector_n::category category;
  75. typedef typename vector_n::is_view is_view;
  76. vector()
  77. : vec() {}
  78. template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
  79. vector(vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, U)> const& rhs)
  80. : vec(rhs.vec) {}
  81. vector(vector const& rhs)
  82. : vec(rhs.vec) {}
  83. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  84. vector(vector&& rhs)
  85. : vec(std::forward<vector_n>(rhs.vec)) {}
  86. #endif
  87. template <typename Sequence>
  88. vector(Sequence const& rhs)
  89. : vec(BOOST_FUSION_VECTOR_COPY_INIT()) {}
  90. // Expand a couple of forwarding constructors for arguments
  91. // of type (T0), (T0, T1), (T0, T1, T2) etc. Example:
  92. //
  93. // vector(
  94. // typename detail::call_param<T0>::type _0
  95. // , typename detail::call_param<T1>::type _1)
  96. // : vec(_0, _1) {}
  97. #include <boost/fusion/container/vector/detail/vector_forward_ctor.hpp>
  98. template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
  99. vector&
  100. operator=(vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, U)> const& rhs)
  101. {
  102. vec = rhs.vec;
  103. return *this;
  104. }
  105. template <typename T>
  106. vector&
  107. operator=(T const& rhs)
  108. {
  109. vec = rhs;
  110. return *this;
  111. }
  112. vector&
  113. operator=(vector const& rhs)
  114. {
  115. vec = rhs.vec;
  116. return *this;
  117. }
  118. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  119. vector&
  120. operator=(vector&& rhs)
  121. {
  122. vec = std::forward<vector_n>(rhs.vec);
  123. return *this;
  124. }
  125. template <typename T>
  126. vector&
  127. operator=(T&& rhs)
  128. {
  129. vec = std::forward<T>(rhs);
  130. return *this;
  131. }
  132. #endif
  133. template <int N>
  134. typename add_reference<
  135. typename mpl::at_c<types, N>::type
  136. >::type
  137. at_impl(mpl::int_<N> index)
  138. {
  139. return vec.at_impl(index);
  140. }
  141. template <int N>
  142. typename add_reference<
  143. typename add_const<
  144. typename mpl::at_c<types, N>::type
  145. >::type
  146. >::type
  147. at_impl(mpl::int_<N> index) const
  148. {
  149. return vec.at_impl(index);
  150. }
  151. template <typename I>
  152. typename add_reference<
  153. typename mpl::at<types, I>::type
  154. >::type
  155. at_impl(I /*index*/)
  156. {
  157. return vec.at_impl(mpl::int_<I::value>());
  158. }
  159. template<typename I>
  160. typename add_reference<
  161. typename add_const<
  162. typename mpl::at<types, I>::type
  163. >::type
  164. >::type
  165. at_impl(I /*index*/) const
  166. {
  167. return vec.at_impl(mpl::int_<I::value>());
  168. }
  169. private:
  170. BOOST_FUSION_VECTOR_CTOR_HELPER()
  171. vector_n vec;
  172. };
  173. }}
  174. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  175. #pragma wave option(output: null)
  176. #endif
  177. #endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES
  178. #endif