vector.hpp 8.8 KB

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