Change fusion::tuple its base class to vector_data.

This change aims to improve compile time performance for both of vector and tuple.
This commit is contained in:
Kohei Takahashi
2017-10-03 22:25:03 +09:00
parent b6e5285430
commit 0471a65ca2

View File

@ -34,13 +34,19 @@
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
template <typename ...T> template <typename ...T>
struct tuple : vector<T...> struct tuple
: vector_detail::vector_data<
typename detail::make_index_sequence<sizeof...(T)>::type
, T...
>
{ {
typedef vector<T...> base_type; typedef vector_detail::vector_data<
typename detail::make_index_sequence<sizeof...(T)>::type
, T...
> base;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
tuple() BOOST_DEFAULTED_FUNCTION(tuple(), {})
: base_type() {}
template < template <
typename ...U typename ...U
@ -50,7 +56,7 @@ namespace boost { namespace fusion
> >
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
tuple(tuple<U...> const& other) tuple(tuple<U...> const& other)
: base_type(other) {} : base(vector_detail::each_elem(), other) {}
template < template <
typename ...U typename ...U
@ -60,7 +66,7 @@ namespace boost { namespace fusion
> >
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
tuple(tuple<U...>&& other) tuple(tuple<U...>&& other)
: base_type(std::move(other)) {} : base(vector_detail::each_elem(), std::move(other)) {}
template < template <
typename ...U typename ...U
@ -72,23 +78,23 @@ namespace boost { namespace fusion
/*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
explicit explicit
tuple(U&&... args) tuple(U&&... args)
: base_type(std::forward<U>(args)...) {} : base(vector_detail::each_elem(), std::forward<U>(args)...) {}
template<typename U1, typename U2> template<typename U1, typename U2>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
tuple(std::pair<U1, U2> const& other) tuple(std::pair<U1, U2> const& other)
: base_type(other.first, other.second) {} : base(vector_detail::each_elem(), other.first, other.second) {}
template<typename U1, typename U2> template<typename U1, typename U2>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
tuple(std::pair<U1, U2>&& other) tuple(std::pair<U1, U2>&& other)
: base_type(std::move(other.first), std::move(other.second)) {} : base(vector_detail::each_elem(), std::move(other.first), std::move(other.second)) {}
template<typename U> template<typename U>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
tuple& operator=(U&& rhs) tuple& operator=(U&& rhs)
{ {
base_type::operator=(std::forward<U>(rhs)); base::assign_sequence(std::forward<U>(rhs));
return *this; return *this;
} }
}; };