Merge pull request #200 from Kojoley/simplify-vector-assign_sequence

vector: Simplify assign_sequence
This commit is contained in:
Joel de Guzman
2021-09-04 14:16:30 +08:00
committed by djowel

View File

@ -168,15 +168,9 @@ namespace boost { namespace fusion
: elem(std::forward<U>(rhs)) : elem(std::forward<U>(rhs))
{} {}
using elem_type = T;
T elem; T elem;
}; };
// placed outside of vector_data due to GCC < 6 bug
template <std::size_t J, typename U>
static inline BOOST_FUSION_GPU_ENABLED
store<J, U> store_at_impl(store<J, U>*);
template <typename I, typename ...T> template <typename I, typename ...T>
struct vector_data; struct vector_data;
@ -228,23 +222,32 @@ namespace boost { namespace fusion
#endif #endif
} }
private: template <std::size_t N, typename U>
template <std::size_t J> static BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
using store_at = decltype(store_at_impl<J>(static_cast<vector_data*>(nullptr))); U& at_detail(store<N, U>* this_)
{
return this_->elem;
}
template <std::size_t N, typename U>
static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
U const& at_detail(store<N, U> const* this_)
{
return this_->elem;
}
public:
template <typename J> template <typename J>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename store_at<J::value>::elem_type& at_impl(J) auto at_impl(J) -> decltype(at_detail<J::value>(&std::declval<vector_data&>()))
{ {
return store_at<J::value>::elem; return at_detail<J::value>(this);
} }
template <typename J> template <typename J>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename store_at<J::value>::elem_type const& at_impl(J) const auto at_impl(J) const -> decltype(at_detail<J::value>(&std::declval<vector_data const&>()))
{ {
return store_at<J::value>::elem; return at_detail<J::value>(this);
} }
}; };
} // namespace boost::fusion::vector_detail } // namespace boost::fusion::vector_detail