mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
fix tuple_element order
This commit is contained in:
parent
403e83eaf0
commit
c9610b5ae5
9 changed files with 70 additions and 63 deletions
|
@ -35,7 +35,7 @@ namespace std {
|
|||
struct tuple_element<I, sprout::integer_sequence<T, Is...> > {
|
||||
static_assert(I < sizeof...(Is), "tuple_element<>: index out of range");
|
||||
public:
|
||||
typedef typename sprout::tppack_c_at<I, T, Is...>::type type;
|
||||
typedef typename sprout::pack_element_c<I, T, Is...>::type type;
|
||||
};
|
||||
|
||||
#if !SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/type_traits/std_type_traits.hpp>
|
||||
#include <sprout/type_traits/is_convert_constructible.hpp>
|
||||
#include <sprout/none.hpp>
|
||||
#include <sprout/optional/nullopt.hpp>
|
||||
|
@ -53,7 +54,7 @@ namespace sprout {
|
|||
public:
|
||||
template<typename... Args>
|
||||
struct is_constructible_args
|
||||
: public std::is_constructible<T, Args&&...>
|
||||
: public sprout::is_constructible<T, Args&&...>
|
||||
{};
|
||||
public:
|
||||
static SPROUT_CONSTEXPR reference_type get(optional& t) SPROUT_NOEXCEPT {
|
||||
|
|
|
@ -267,8 +267,8 @@ namespace sprout {
|
|||
struct is_flexibly_convert_constructible_impl<sprout::index_tuple<Indexes...>, Utypes...>
|
||||
: public sprout::tpp::all_of<
|
||||
sprout::is_convert_constructible<
|
||||
typename sprout::tppack_at<Indexes, Types...>::type,
|
||||
typename sprout::tppack_at<Indexes, Utypes...>::type
|
||||
typename sprout::pack_element<Indexes, Types...>::type,
|
||||
typename sprout::pack_element<Indexes, Utypes...>::type
|
||||
>...
|
||||
>
|
||||
{};
|
||||
|
@ -466,20 +466,6 @@ namespace sprout {
|
|||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element_impl;
|
||||
template<typename Head, typename... Tail>
|
||||
struct tuple_element_impl<0, sprout::tuples::tuple<Head, Tail...> > {
|
||||
public:
|
||||
typedef Head type;
|
||||
};
|
||||
template<std::size_t I, typename Head, typename... Tail>
|
||||
struct tuple_element_impl<I, sprout::tuples::tuple<Head, Tail...> >
|
||||
: public sprout::tuples::detail::tuple_element_impl<I - 1, sprout::tuples::tuple<Tail...> >
|
||||
{};
|
||||
} // namespace detail
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::tuple;
|
||||
|
@ -504,7 +490,7 @@ namespace std {
|
|||
//
|
||||
template<std::size_t I, typename... Types>
|
||||
struct tuple_element<I, sprout::tuples::tuple<Types...> >
|
||||
: public sprout::tuples::detail::tuple_element_impl<I, sprout::tuples::tuple<Types...> >
|
||||
: public sprout::pack_element<I, Types...>
|
||||
{};
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <tuple>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/detail/type_traits_wrapper.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
|
@ -18,7 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct tuple_size
|
||||
: public std::tuple_size<T>
|
||||
: public sprout::detail::type_traits_wrapper<std::tuple_size<T> >
|
||||
{};
|
||||
template<typename T>
|
||||
struct tuple_size<T const>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <cstddef>
|
||||
#include <tuple>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/detail/type_traits_wrapper.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
|
@ -34,7 +35,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T, typename Enable = void>
|
||||
struct tuple_size
|
||||
: public std::tuple_size<T>
|
||||
: public sprout::detail::type_traits_wrapper<std::tuple_size<T> >
|
||||
{};
|
||||
//
|
||||
// tuple_element
|
||||
|
|
|
@ -10,12 +10,14 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/iterator.hpp>
|
||||
#include <sprout/type/iterator/index_iterator.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
|
@ -48,16 +50,41 @@ namespace sprout {
|
|||
};
|
||||
|
||||
namespace detail {
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element_impl;
|
||||
template<typename T>
|
||||
struct tuple_head;
|
||||
template<typename Head, typename... Tail>
|
||||
struct tuple_element_impl<0, sprout::types::type_tuple<Head, Tail...> > {
|
||||
public:
|
||||
typedef Head type;
|
||||
};
|
||||
template<std::size_t I, typename Head, typename... Tail>
|
||||
struct tuple_element_impl<I, sprout::types::type_tuple<Head, Tail...> >
|
||||
: public sprout::types::detail::tuple_element_impl<I - 1, sprout::types::type_tuple<Tail...> >
|
||||
struct tuple_head<sprout::types::type_tuple<Head, Tail...> >
|
||||
: public sprout::identity<Head>
|
||||
{};
|
||||
|
||||
template<std::size_t I, std::size_t N, typename T, typename Enable = void>
|
||||
struct tuple_skip;
|
||||
template<std::size_t I, std::size_t N, typename Head, typename... Tail>
|
||||
struct tuple_skip<
|
||||
I, N, sprout::types::type_tuple<Head, Tail...>,
|
||||
typename std::enable_if<(I == 0)>::type
|
||||
>
|
||||
: public sprout::identity<sprout::types::type_tuple<Head, Tail...> >
|
||||
{};
|
||||
template<std::size_t I, std::size_t N, typename Head, typename... Tail>
|
||||
struct tuple_skip<
|
||||
I, N, sprout::types::type_tuple<Head, Tail...>,
|
||||
typename std::enable_if<(I != 0 && I < N / 2)>::type
|
||||
>
|
||||
: public sprout::types::detail::tuple_skip<
|
||||
I - 1, N / 2 - 1,
|
||||
sprout::types::type_tuple<Tail...>
|
||||
>
|
||||
{};
|
||||
template<std::size_t I, std::size_t N, typename Head, typename... Tail>
|
||||
struct tuple_skip<
|
||||
I, N, sprout::types::type_tuple<Head, Tail...>,
|
||||
typename std::enable_if<(I != 0 && I >= N / 2)>::type
|
||||
>
|
||||
: public sprout::types::detail::tuple_skip<
|
||||
I - N / 2, N - N / 2,
|
||||
typename sprout::types::detail::tuple_skip<N / 2 - 1, N / 2, sprout::types::type_tuple<Tail...> >::type
|
||||
>
|
||||
{};
|
||||
} // namespace detail
|
||||
} // namespace types
|
||||
|
@ -84,7 +111,9 @@ namespace std {
|
|||
//
|
||||
template<std::size_t I, typename... Types>
|
||||
struct tuple_element<I, sprout::types::type_tuple<Types...> >
|
||||
: public sprout::types::detail::tuple_element_impl<I, sprout::types::type_tuple<Types...> >
|
||||
: public sprout::types::detail::tuple_head<
|
||||
typename sprout::types::detail::tuple_skip<I, sizeof...(Types), sprout::types::type_tuple<Types...> >::type
|
||||
>
|
||||
{};
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
|
|
|
@ -27,6 +27,10 @@ namespace sprout {
|
|||
operator value_type() const SPROUT_NOEXCEPT {
|
||||
return std::integral_constant<T, v>::value;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool
|
||||
operator!() const SPROUT_NOEXCEPT {
|
||||
return !std::integral_constant<T, v>::value;
|
||||
}
|
||||
SPROUT_CONSTEXPR value_type
|
||||
operator()() const SPROUT_NOEXCEPT {
|
||||
return std::integral_constant<T, v>::value;
|
||||
|
|
|
@ -11,45 +11,29 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// tppack_at
|
||||
// pack_element
|
||||
//
|
||||
namespace detail {
|
||||
template<std::size_t I, typename Head, typename... Tail>
|
||||
struct tppack_at_impl_1
|
||||
: public sprout::detail::tppack_at_impl_1<I - 1, Tail...>
|
||||
{};
|
||||
template<typename Head, typename... Tail>
|
||||
struct tppack_at_impl_1<0, Head, Tail...> {
|
||||
public:
|
||||
typedef Head type;
|
||||
};
|
||||
template<std::size_t I, typename... Args>
|
||||
struct tppack_at_impl
|
||||
: public sprout::detail::tppack_at_impl_1<I, Args...>
|
||||
{
|
||||
static_assert(I < sizeof...(Args), "I < sizeof...(Args)");
|
||||
};
|
||||
} // namespace detail
|
||||
template<std::size_t I, typename... Args>
|
||||
struct tppack_at
|
||||
: public sprout::detail::tppack_at_impl<I, Args...>
|
||||
struct pack_element
|
||||
: public std::tuple_element<I, sprout::types::type_tuple<Args...> >
|
||||
{};
|
||||
|
||||
//
|
||||
// tppack_c_at
|
||||
// pack_element_c
|
||||
//
|
||||
template<std::size_t I, typename T, T... Args>
|
||||
struct tppack_c_at
|
||||
: public sprout::tppack_at<I, sprout::integral_constant<T, Args>...>::type
|
||||
struct pack_element_c
|
||||
: public sprout::pack_element<I, sprout::integral_constant<T, Args>...>::type
|
||||
{};
|
||||
|
||||
//
|
||||
// fppack_at
|
||||
// pack_get
|
||||
//
|
||||
namespace detail {
|
||||
template<
|
||||
|
@ -57,7 +41,7 @@ namespace sprout {
|
|||
typename sprout::enabler_if<I == 0>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR R
|
||||
fppack_at_impl(Head&& head, Tail&&...) {
|
||||
pack_get_impl(Head&& head, Tail&&...) {
|
||||
return sprout::forward<Head>(head);
|
||||
}
|
||||
template<
|
||||
|
@ -65,16 +49,16 @@ namespace sprout {
|
|||
typename sprout::enabler_if<I != 0>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR R
|
||||
fppack_at_impl(Head&&, Tail&&... tail) {
|
||||
return sprout::detail::fppack_at_impl<I - 1, R>(sprout::forward<Tail>(tail)...);
|
||||
pack_get_impl(Head&&, Tail&&... tail) {
|
||||
return sprout::detail::pack_get_impl<I - 1, R>(sprout::forward<Tail>(tail)...);
|
||||
}
|
||||
} // namespace detail
|
||||
template<std::size_t I, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tppack_at<I, Args&&...>::type
|
||||
fppack_at(Args&&... args) {
|
||||
return sprout::detail::fppack_at_impl<
|
||||
inline SPROUT_CONSTEXPR typename sprout::pack_element<I, Args&&...>::type
|
||||
pack_get(Args&&... args) {
|
||||
return sprout::detail::pack_get_impl<
|
||||
I,
|
||||
typename sprout::tppack_at<I, Args&&...>::type
|
||||
typename sprout::pack_element<I, Args&&...>::type
|
||||
>(sprout::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/type_traits/std_type_traits.hpp>
|
||||
#include <sprout/optional/in_place.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -184,7 +185,7 @@ namespace sprout {
|
|||
public:
|
||||
template<typename... Args>
|
||||
struct is_constructible_args
|
||||
: public std::is_constructible<T, Args&&...>
|
||||
: public sprout::is_constructible<T, Args&&...>
|
||||
{};
|
||||
public:
|
||||
static SPROUT_CONSTEXPR reference get(value_holder& t) SPROUT_NOEXCEPT {
|
||||
|
|
Loading…
Reference in a new issue