1 /*=============================================================================
2 Copyright (c) 2001-2006 Joel de Guzman
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
10 #include <boost/fusion/container/vector/vector_fwd.hpp>
11 #include <boost/fusion/container/vector/detail/vector_n_chooser.hpp>
12 #include <boost/fusion/sequence/intrinsic/begin.hpp>
13 #include <boost/mpl/at.hpp>
14 #include <boost/mpl/bool.hpp>
15 #include <boost/type_traits/add_reference.hpp>
16 #include <boost/type_traits/add_const.hpp>
17 #include <boost/type_traits/is_base_of.hpp>
18 #include <boost/detail/workaround.hpp>
20 namespace boost { namespace fusion
23 struct fusion_sequence_tag;
25 template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
27 : sequence_base<vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)> >
31 typedef typename detail::vector_n_chooser<
32 BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>::type
35 template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
40 typedef typename vector_n::types types;
41 typedef typename vector_n::fusion_tag fusion_tag;
42 typedef typename vector_n::tag tag;
43 typedef typename vector_n::size size;
44 typedef typename vector_n::category category;
45 typedef typename vector_n::is_view is_view;
50 template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
51 vector(vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, U)> const& rhs)
54 vector(vector const& rhs)
57 template <typename Sequence>
58 vector(Sequence const& rhs)
59 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1600)
60 : vec(ctor_helper(rhs, is_base_of<vector, Sequence>())) {}
65 // Expand a couple of forwarding constructors for arguments
66 // of type (T0), (T0, T1), (T0, T1, T2) etc. Example:
69 // typename detail::call_param<T0>::type _0
70 // , typename detail::call_param<T1>::type _1)
72 #include <boost/fusion/container/vector/detail/vector_forward_ctor.hpp>
74 template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
76 operator=(vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, U)> const& rhs)
84 operator=(T const& rhs)
91 typename add_reference<
92 typename mpl::at_c<types, N>::type
94 at_impl(mpl::int_<N> index)
96 return vec.at_impl(index);
100 typename add_reference<
102 typename mpl::at_c<types, N>::type
105 at_impl(mpl::int_<N> index) const
107 return vec.at_impl(index);
110 template <typename I>
111 typename add_reference<
112 typename mpl::at<types, I>::type
116 return vec.at_impl(mpl::int_<I::value>());
120 typename add_reference<
122 typename mpl::at<types, I>::type
125 at_impl(I /*index*/) const
127 return vec.at_impl(mpl::int_<I::value>());
132 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1600)
133 static vector_n const&
134 ctor_helper(vector const& rhs, mpl::true_)
139 template <typename T>
141 ctor_helper(T const& rhs, mpl::false_)