mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
fix tuple get adapt-interfaces
This commit is contained in:
parent
0c00166c5f
commit
2dcafaa98d
10 changed files with 265 additions and 266 deletions
|
@ -3,35 +3,32 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sscrisk/cel/array.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sscrisk/cel/array.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// get
|
||||
//
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&
|
||||
get(sscrisk::cel::array<T, N>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
get(sscrisk::cel::array<T, N> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&&
|
||||
get(sscrisk::cel::array<T, N>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(sprout::tuples::get<I>(t));
|
||||
}
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::get;
|
||||
} // namespace sprout
|
||||
namespace sprout_adl {
|
||||
//
|
||||
// tuple_get
|
||||
//
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&
|
||||
tuple_get(sscrisk::cel::array<T, N>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
tuple_get(sscrisk::cel::array<T, N> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&&
|
||||
tuple_get(sscrisk::cel::array<T, N>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(sprout::tuples::get<I>(t));
|
||||
}
|
||||
} // namespace sprout_adl
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_SSCRISK_CEL_ARRAY_HPP
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <type_traits>
|
||||
#include <sscrisk/cel/utility.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
|
@ -18,9 +18,6 @@ namespace sprout {
|
|||
: public std::integral_constant<std::size_t, 2>
|
||||
{};
|
||||
|
||||
//
|
||||
// tuple_element
|
||||
//
|
||||
namespace detail {
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element_impl;
|
||||
|
@ -35,14 +32,14 @@ namespace sprout {
|
|||
typedef T2 type;
|
||||
};
|
||||
} // namespace detail
|
||||
//
|
||||
// tuple_element
|
||||
//
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
struct tuple_element<I, sscrisk::cel::pair<T1, T2> >
|
||||
: public sprout::tuples::detail::tuple_element_impl<I, sscrisk::cel::pair<T1, T2> >
|
||||
{};
|
||||
|
||||
//
|
||||
// get
|
||||
//
|
||||
namespace detail {
|
||||
template<std::size_t I, typename T>
|
||||
struct get_impl;
|
||||
|
@ -68,26 +65,33 @@ namespace sprout {
|
|||
}
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout_adl {
|
||||
//
|
||||
// tuple_get
|
||||
//
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&
|
||||
get(sscrisk::cel::pair<T1, T2>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "get: index out of range");
|
||||
tuple_get(sscrisk::cel::pair<T1, T2>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type const&
|
||||
get(sscrisk::cel::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "get: index out of range");
|
||||
tuple_get(sscrisk::cel::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&&
|
||||
get(sscrisk::cel::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
|
||||
tuple_get(sscrisk::cel::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(sprout::tuples::get<I>(t));
|
||||
}
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::get;
|
||||
} // namespace sprout
|
||||
} // namespace sprout_adl
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_SSCRISK_CEL_UTILITY_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue