mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-30 04:27:30 +02:00
Merge pull request #151 from boostorg/change-base-of-tuple
Change base of tuple
This commit is contained in:
@ -23,7 +23,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||||
#include <boost/type_traits/declval.hpp>
|
#include <boost/type_traits/declval.hpp>
|
||||||
#include <boost/type_traits/remove_cv.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
@ -31,8 +30,12 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
namespace vector_detail
|
namespace vector_detail
|
||||||
{
|
{
|
||||||
template <typename I, typename ...T>
|
template <std::size_t I, typename T>
|
||||||
struct vector_data;
|
struct store;
|
||||||
|
|
||||||
|
template <std::size_t N, typename U>
|
||||||
|
static inline BOOST_FUSION_GPU_ENABLED
|
||||||
|
U value_at_impl(store<N, U> const volatile*);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
@ -46,8 +49,9 @@ namespace boost { namespace fusion
|
|||||||
template <typename Sequence, typename N>
|
template <typename Sequence, typename N>
|
||||||
struct apply
|
struct apply
|
||||||
{
|
{
|
||||||
typedef typename boost::remove_cv<Sequence>::type seq;
|
typedef
|
||||||
typedef typename mpl::identity<decltype(seq::template value_at_impl<N::value>(boost::declval<seq*>()))>::type::type type;
|
decltype(vector_detail::value_at_impl<N::value>(boost::declval<Sequence*>()))
|
||||||
|
type;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -133,27 +133,27 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
store(store const& rhs)
|
store(store const& rhs)
|
||||||
: elem(rhs.get())
|
: elem(rhs.elem)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
store&
|
store&
|
||||||
operator=(store const& rhs)
|
operator=(store const& rhs)
|
||||||
{
|
{
|
||||||
elem = rhs.get();
|
elem = rhs.elem;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
store(store&& rhs)
|
store(store&& rhs)
|
||||||
: elem(static_cast<T&&>(rhs.get()))
|
: elem(static_cast<T&&>(rhs.elem))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
store&
|
store&
|
||||||
operator=(store&& rhs)
|
operator=(store&& rhs)
|
||||||
{
|
{
|
||||||
elem = static_cast<T&&>(rhs.get());
|
elem = static_cast<T&&>(rhs.elem);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,11 +168,6 @@ namespace boost { namespace fusion
|
|||||||
: elem(std::forward<U>(rhs))
|
: elem(std::forward<U>(rhs))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
|
||||||
T & get() { return elem; }
|
|
||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
|
||||||
T const& get() const { return elem; }
|
|
||||||
|
|
||||||
T elem;
|
T elem;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -192,8 +187,7 @@ namespace boost { namespace fusion
|
|||||||
typedef vector<T...> type_sequence;
|
typedef vector<T...> type_sequence;
|
||||||
|
|
||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
vector_data()
|
BOOST_DEFAULTED_FUNCTION(vector_data(), {})
|
||||||
{}
|
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename Sequence
|
typename Sequence
|
||||||
@ -239,16 +233,16 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
template <std::size_t N, typename U>
|
template <std::size_t N, typename U>
|
||||||
static BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
static BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
auto at_detail(store<N, U>* this_) -> decltype(this_->get())
|
U& at_detail(store<N, U>* this_)
|
||||||
{
|
{
|
||||||
return this_->get();
|
return this_->elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t N, typename U>
|
template <std::size_t N, typename U>
|
||||||
static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
auto at_detail(store<N, U> const* this_) -> decltype(this_->get())
|
U const& at_detail(store<N, U> const* this_)
|
||||||
{
|
{
|
||||||
return this_->get();
|
return this_->elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename J>
|
template <typename J>
|
||||||
@ -264,10 +258,6 @@ namespace boost { namespace fusion
|
|||||||
{
|
{
|
||||||
return at_detail<J::value>(this);
|
return at_detail<J::value>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t N, typename U>
|
|
||||||
static BOOST_FUSION_GPU_ENABLED
|
|
||||||
mpl::identity<U> value_at_impl(store<N, U>*);
|
|
||||||
};
|
};
|
||||||
} // namespace boost::fusion::vector_detail
|
} // namespace boost::fusion::vector_detail
|
||||||
|
|
||||||
@ -284,8 +274,7 @@ namespace boost { namespace fusion
|
|||||||
> base;
|
> base;
|
||||||
|
|
||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
vector()
|
BOOST_DEFAULTED_FUNCTION(vector(), {})
|
||||||
{}
|
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename... U
|
typename... U
|
||||||
@ -306,13 +295,11 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
typename Sequence
|
typename Sequence
|
||||||
, typename Sequence_ = typename remove_reference<Sequence>::type
|
, typename = typename boost::enable_if_c<
|
||||||
, typename = typename boost::enable_if_c<(
|
|
||||||
!is_base_of<vector, Sequence_>::value &&
|
|
||||||
vector_detail::is_longer_sequence<
|
vector_detail::is_longer_sequence<
|
||||||
Sequence_, sizeof...(T)
|
typename remove_reference<Sequence>::type, sizeof...(T)
|
||||||
>::value
|
>::value
|
||||||
)>::type
|
>::type
|
||||||
>
|
>
|
||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
vector(Sequence&& seq)
|
vector(Sequence&& seq)
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user