PageRenderTime 29ms CodeModel.GetById 9ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://hadesmem.googlecode.com/
C++ Header | 151 lines | 115 code | 23 blank | 13 comment | 0 complexity | 4c913c617d07d46e572511774243f747 MD5 | raw file
  1/*=============================================================================
  2    Copyright (c) 2001-2006 Joel de Guzman
  3
  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
 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>
 19
 20namespace boost { namespace fusion
 21{
 22    struct void_;
 23    struct fusion_sequence_tag;
 24
 25    template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
 26    struct vector
 27        : sequence_base<vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)> >
 28    {
 29    private:
 30
 31        typedef typename detail::vector_n_chooser<
 32            BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>::type
 33        vector_n;
 34
 35        template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
 36        friend struct vector;
 37
 38    public:
 39
 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;
 46
 47        vector()
 48            : vec() {}
 49
 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)
 52            : vec(rhs.vec) {}
 53
 54        vector(vector const& rhs)
 55            : vec(rhs.vec) {}
 56
 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>())) {}
 61#else
 62            : vec(rhs) {}
 63#endif
 64
 65        //  Expand a couple of forwarding constructors for arguments
 66        //  of type (T0), (T0, T1), (T0, T1, T2) etc. Example:
 67        //
 68        //  vector(
 69        //      typename detail::call_param<T0>::type _0
 70        //    , typename detail::call_param<T1>::type _1)
 71        //    : vec(_0, _1) {}
 72        #include <boost/fusion/container/vector/detail/vector_forward_ctor.hpp>
 73
 74        template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
 75        vector&
 76        operator=(vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, U)> const& rhs)
 77        {
 78            vec = rhs.vec;
 79            return *this;
 80        }
 81
 82        template <typename T>
 83        vector&
 84        operator=(T const& rhs)
 85        {
 86            vec = rhs;
 87            return *this;
 88        }
 89
 90        template <int N>
 91        typename add_reference<
 92            typename mpl::at_c<types, N>::type
 93        >::type
 94        at_impl(mpl::int_<N> index)
 95        {
 96            return vec.at_impl(index);
 97        }
 98
 99        template <int N>
100        typename add_reference<
101            typename add_const<
102                typename mpl::at_c<types, N>::type
103            >::type
104        >::type
105        at_impl(mpl::int_<N> index) const
106        {
107            return vec.at_impl(index);
108        }
109
110        template <typename I>
111        typename add_reference<
112            typename mpl::at<types, I>::type
113        >::type
114        at_impl(I /*index*/)
115        {
116            return vec.at_impl(mpl::int_<I::value>());
117        }
118
119        template<typename I>
120        typename add_reference<
121            typename add_const<
122                typename mpl::at<types, I>::type
123            >::type
124        >::type
125        at_impl(I /*index*/) const
126        {
127            return vec.at_impl(mpl::int_<I::value>());
128        }
129
130    private:
131
132#if BOOST_WORKAROUND(BOOST_MSVC, <= 1600)
133        static vector_n const&
134        ctor_helper(vector const& rhs, mpl::true_)
135        {
136            return rhs.vec;
137        }
138
139        template <typename T>
140        static T const&
141        ctor_helper(T const& rhs, mpl::false_)
142        {
143            return rhs;
144        }
145#endif
146
147        vector_n vec;
148    };
149}}
150
151#endif