forked from boostorg/fusion
move-assign for vector
[SVN r80345]
This commit is contained in:
@ -131,13 +131,6 @@ namespace boost { namespace fusion
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
template <typename ...Elements>
|
||||
deque& operator=(deque<Elements...>&& rhs)
|
||||
{
|
||||
base::operator=(std::forward<deque<Elements...>>(rhs));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
deque& operator=(T&& rhs)
|
||||
{
|
||||
|
@ -135,15 +135,6 @@ namespace boost { namespace fusion {
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, typename U)>
|
||||
deque&
|
||||
operator=(deque<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, U)>&& rhs)
|
||||
{
|
||||
base::operator=(std::forward<
|
||||
deque<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, U)>>(rhs));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
deque&
|
||||
operator=(T&& rhs)
|
||||
|
@ -124,14 +124,6 @@ namespace boost { namespace fusion { namespace detail
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
template<typename U, typename Rst>
|
||||
keyed_element& operator=(keyed_element<Key, U, Rst>&& rhs)
|
||||
{
|
||||
base::operator=(std::forward<keyed_element<Key, U, Rst>>(rhs));
|
||||
value_ = std::forward<U>(rhs.value_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
keyed_element& operator=(keyed_element&& rhs)
|
||||
{
|
||||
base::operator=(std::forward<keyed_element>(rhs));
|
||||
|
@ -9,27 +9,31 @@
|
||||
#if !defined(FUSION_MACRO_05042005)
|
||||
#define FUSION_MACRO_05042005
|
||||
|
||||
#define FUSION_MEMBER_DEFAULT_INIT(z, n, _) m##n()
|
||||
#define FUSION_MEMBER_INIT(z, n, _) m##n(_##n)
|
||||
#define FUSION_COPY_INIT(z, n, _) m##n(other.m##n)
|
||||
#define FUSION_MOVE_FROM_OTHER(z, n, _) m##n(std::move(other.m##n))
|
||||
#define FUSION_MOVE(z, n, _) m##n(std::move(_##n))
|
||||
#define FUSION_MEMBER_DECL(z, n, _) T##n m##n;
|
||||
#define FUSION_FORWARD(z, n, _) std::forward<T##n>(_##n)
|
||||
#define FUSION_VECTOR_MEMBER_MEMBER_DEFAULT_INIT(z, n, _) m##n()
|
||||
#define FUSION_VECTOR_MEMBER_MEMBER_INIT(z, n, _) m##n(_##n)
|
||||
#define FUSION_VECTOR_MEMBER_COPY_INIT(z, n, _) m##n(other.m##n)
|
||||
#define FUSION_VECTOR_MEMBER_FWD(z, n, _) m##n(std::forward<T##n>(other.m##n))
|
||||
#define FUSION_VECTOR_ARG_FWD(z, n, _) m##n(std::forward<T##n>(_##n))
|
||||
#define FUSION_VECTOR_MEMBER_MEMBER_DECL(z, n, _) T##n m##n;
|
||||
#define FUSION_VECTOR_MEMBER_FORWARD(z, n, _) std::forward<T##n>(_##n)
|
||||
|
||||
#define FUSION_MEMBER_ASSIGN(z, n, _) \
|
||||
#define FUSION_VECTOR_MEMBER_MEMBER_ASSIGN(z, n, _) \
|
||||
this->BOOST_PP_CAT(m, n) = vec.BOOST_PP_CAT(m, n);
|
||||
|
||||
#define FUSION_DEREF_MEMBER_ASSIGN(z, n, _) \
|
||||
#define FUSION_VECTOR_MEMBER_DEREF_MEMBER_ASSIGN(z, n, _) \
|
||||
this->BOOST_PP_CAT(m, n) = *BOOST_PP_CAT(i, n);
|
||||
|
||||
#define FUSION_AT_IMPL(z, n, _) \
|
||||
#define FUSION_VECTOR_MEMBER_MEMBER_FORWARD(z, n, _) \
|
||||
this->BOOST_PP_CAT(m, n) = std::forward< \
|
||||
BOOST_PP_CAT(T, n)>(vec.BOOST_PP_CAT(m, n));
|
||||
|
||||
#define FUSION_VECTOR_MEMBER_AT_IMPL(z, n, _) \
|
||||
typename add_reference<T##n>::type \
|
||||
at_impl(mpl::int_<n>) { return this->m##n; } \
|
||||
typename add_reference<typename add_const<T##n>::type>::type \
|
||||
at_impl(mpl::int_<n>) const { return this->m##n; }
|
||||
|
||||
#define FUSION_ITER_DECL_VAR(z, n, _) \
|
||||
#define FUSION_VECTOR_MEMBER_ITER_DECL_VAR(z, n, _) \
|
||||
typedef typename result_of::next< \
|
||||
BOOST_PP_CAT(I, BOOST_PP_DEC(n))>::type BOOST_PP_CAT(I, n); \
|
||||
BOOST_PP_CAT(I, n) BOOST_PP_CAT(i, n) \
|
||||
@ -43,32 +47,32 @@
|
||||
struct BOOST_PP_CAT(vector_data, N)
|
||||
{
|
||||
BOOST_PP_CAT(vector_data, N)()
|
||||
: BOOST_PP_ENUM(N, FUSION_MEMBER_DEFAULT_INIT, _) {}
|
||||
: BOOST_PP_ENUM(N, FUSION_VECTOR_MEMBER_MEMBER_DEFAULT_INIT, _) {}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
BOOST_PP_CAT(vector_data, N)(BOOST_PP_ENUM_BINARY_PARAMS(N, T, && _))
|
||||
: BOOST_PP_ENUM(N, FUSION_MOVE, _) {}
|
||||
: BOOST_PP_ENUM(N, FUSION_VECTOR_ARG_FWD, _) {}
|
||||
#endif
|
||||
|
||||
BOOST_PP_CAT(vector_data, N)(
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(
|
||||
N, typename detail::call_param<T, >::type _))
|
||||
: BOOST_PP_ENUM(N, FUSION_MEMBER_INIT, _) {}
|
||||
: BOOST_PP_ENUM(N, FUSION_VECTOR_MEMBER_MEMBER_INIT, _) {}
|
||||
|
||||
BOOST_PP_CAT(vector_data, N)(
|
||||
BOOST_PP_CAT(vector_data, N) const& other)
|
||||
: BOOST_PP_ENUM(N, FUSION_COPY_INIT, _) {}
|
||||
: BOOST_PP_ENUM(N, FUSION_VECTOR_MEMBER_COPY_INIT, _) {}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
BOOST_PP_CAT(vector_data, N)(
|
||||
BOOST_PP_CAT(vector_data, N)&& other)
|
||||
: BOOST_PP_ENUM(N, FUSION_MOVE_FROM_OTHER, _) {}
|
||||
: BOOST_PP_ENUM(N, FUSION_VECTOR_MEMBER_FWD, _) {}
|
||||
#endif
|
||||
|
||||
BOOST_PP_CAT(vector_data, N)&
|
||||
operator=(BOOST_PP_CAT(vector_data, N) const& vec)
|
||||
{
|
||||
BOOST_PP_REPEAT(N, FUSION_MEMBER_ASSIGN, _)
|
||||
BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_MEMBER_ASSIGN, _)
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -78,7 +82,7 @@
|
||||
{
|
||||
typedef typename result_of::begin<Sequence const>::type I0;
|
||||
I0 i0 = fusion::begin(seq);
|
||||
BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_ITER_DECL_VAR, _)
|
||||
BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_VECTOR_MEMBER_ITER_DECL_VAR, _)
|
||||
return BOOST_PP_CAT(vector_data, N)(BOOST_PP_ENUM_PARAMS(N, *i));
|
||||
}
|
||||
|
||||
@ -88,11 +92,11 @@
|
||||
{
|
||||
typedef typename result_of::begin<Sequence>::type I0;
|
||||
I0 i0 = fusion::begin(seq);
|
||||
BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_ITER_DECL_VAR, _)
|
||||
BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_VECTOR_MEMBER_ITER_DECL_VAR, _)
|
||||
return BOOST_PP_CAT(vector_data, N)(BOOST_PP_ENUM_PARAMS(N, *i));
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT(N, FUSION_MEMBER_DECL, _)
|
||||
BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_MEMBER_DECL, _)
|
||||
};
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(N, typename T)>
|
||||
@ -124,12 +128,12 @@
|
||||
explicit
|
||||
#endif
|
||||
BOOST_PP_CAT(vector, N)(BOOST_PP_ENUM_BINARY_PARAMS(N, T, && _))
|
||||
: base_type(BOOST_PP_ENUM(N, FUSION_FORWARD, _)) {}
|
||||
: base_type(BOOST_PP_ENUM(N, FUSION_VECTOR_MEMBER_FORWARD, _)) {}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
BOOST_PP_CAT(vector, N)(BOOST_PP_CAT(vector, N)&& rhs)
|
||||
: base_type(std::move(rhs)) {}
|
||||
: base_type(std::forward<base_type>(rhs)) {}
|
||||
#endif
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(N, typename U)>
|
||||
@ -159,7 +163,7 @@
|
||||
BOOST_PP_CAT(vector, N)&
|
||||
operator=(BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, U)> const& vec)
|
||||
{
|
||||
BOOST_PP_REPEAT(N, FUSION_MEMBER_ASSIGN, _)
|
||||
BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_MEMBER_ASSIGN, _)
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -169,12 +173,21 @@
|
||||
{
|
||||
typedef typename result_of::begin<Sequence const>::type I0;
|
||||
I0 i0 = fusion::begin(seq);
|
||||
BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_ITER_DECL_VAR, _)
|
||||
BOOST_PP_REPEAT(N, FUSION_DEREF_MEMBER_ASSIGN, _)
|
||||
BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_VECTOR_MEMBER_ITER_DECL_VAR, _)
|
||||
BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_DEREF_MEMBER_ASSIGN, _)
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT(N, FUSION_AT_IMPL, _)
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
BOOST_PP_CAT(vector, N)&
|
||||
operator=(BOOST_PP_CAT(vector, N)&& vec)
|
||||
{
|
||||
BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_MEMBER_FORWARD, _)
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_AT_IMPL, _)
|
||||
|
||||
template<typename I>
|
||||
typename add_reference<typename mpl::at<types, I>::type>::type
|
||||
|
@ -108,7 +108,7 @@ namespace boost { namespace fusion
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
vector(vector&& rhs)
|
||||
: vec(std::move(rhs.vec)) {}
|
||||
: vec(std::forward<vector_n>(rhs.vec)) {}
|
||||
#endif
|
||||
|
||||
template <typename Sequence>
|
||||
@ -140,6 +140,23 @@ namespace boost { namespace fusion
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
vector&
|
||||
operator=(vector&& rhs)
|
||||
{
|
||||
vec = std::forward<vector_n>(rhs.vec);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vector&
|
||||
operator=(T&& rhs)
|
||||
{
|
||||
vec = std::forward<T>(rhs);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <int N>
|
||||
typename add_reference<
|
||||
typename mpl::at_c<types, N>::type
|
||||
|
Reference in New Issue
Block a user