Added move ctor/assign for c++11 fusion::list.

This commit is contained in:
Kohei Takahashi
2015-06-24 15:26:33 +09:00
parent 5cceded23b
commit d5ce74dffd

View File

@ -20,12 +20,12 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// C++11 interface // C++11 interface
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <utility>
#include <boost/fusion/container/list/detail/list_to_cons.hpp> #include <boost/fusion/container/list/detail/list_to_cons.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
struct nil_; struct nil_;
struct void_;
template <> template <>
struct list<> struct list<>
@ -40,6 +40,7 @@ namespace boost { namespace fusion
list() list()
: inherited_type() {} : inherited_type() {}
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <typename Sequence> template <typename Sequence>
BOOST_FUSION_GPU_ENABLED BOOST_FUSION_GPU_ENABLED
list(Sequence const& rhs) list(Sequence const& rhs)
@ -53,6 +54,21 @@ namespace boost { namespace fusion
inherited_type::operator=(rhs); inherited_type::operator=(rhs);
return *this; return *this;
} }
#else
template <typename Sequence>
BOOST_FUSION_GPU_ENABLED
list(Sequence&& rhs)
: inherited_type(std::forward<Sequence>(rhs)) {}
template <typename Sequence>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
list&
operator=(Sequence&& rhs)
{
inherited_type::operator=(std::forward<Sequence>(rhs));
return *this;
}
#endif
}; };
template <typename ...T> template <typename ...T>
@ -68,30 +84,24 @@ namespace boost { namespace fusion
list() list()
: inherited_type() {} : inherited_type() {}
template <typename ...U> #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
list(list<U...> const& rhs)
: inherited_type(rhs) {}
template <typename Sequence> template <typename Sequence>
BOOST_FUSION_GPU_ENABLED BOOST_FUSION_GPU_ENABLED
list(Sequence const& rhs) list(Sequence const& rhs)
: inherited_type(rhs) {} : inherited_type(rhs) {}
#else
template <typename Sequence>
BOOST_FUSION_GPU_ENABLED
list(Sequence&& rhs)
: inherited_type(std::forward<Sequence>(rhs)) {}
#endif
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
explicit explicit
list(typename detail::call_param<T>::type ...args) list(typename detail::call_param<T>::type ...args)
: inherited_type(list_to_cons::call(args...)) {} : inherited_type(list_to_cons::call(args...)) {}
template <typename ...U> #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
list&
operator=(list<U...> const& rhs)
{
inherited_type::operator=(rhs);
return *this;
}
template <typename Sequence> template <typename Sequence>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
list& list&
@ -100,6 +110,16 @@ namespace boost { namespace fusion
inherited_type::operator=(rhs); inherited_type::operator=(rhs);
return *this; return *this;
} }
#else
template <typename Sequence>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
list&
operator=(Sequence&& rhs)
{
inherited_type::operator=(std::forward<Sequence>(rhs));
return *this;
}
#endif
}; };
}} }}