Remove unused size traits

This commit is contained in:
Denis Blank 2018-03-14 07:38:13 +01:00
parent 3a5cea7779
commit 358e13e06e
2 changed files with 1 additions and 33 deletions

View File

@ -86,38 +86,6 @@ template <typename... T>
using void_t = typename detail::deduce_to_void<T...>::type;
#endif // CONTINUABLE_HAS_CXX17_VOID_T
namespace detail {
/// Evaluates to the size of the given tuple like type,
// / if the type has no static size it will be one.
template <typename T, typename Enable = void>
struct tuple_like_size : std::integral_constant<std::size_t, 1U> {};
template <typename T>
struct tuple_like_size<T, void_t<decltype(std::tuple_size<T>::value)>>
: std::tuple_size<T> {};
} // namespace detail
/// Returns the pack size of the given empty pack
constexpr std::size_t pack_size_of(identity<>) noexcept {
return 0U;
}
/// Returns the pack size of the given type
template <typename T>
constexpr std::size_t pack_size_of(identity<T>) noexcept {
return detail::tuple_like_size<T>::value;
}
/// Returns the pack size of the given type
template <typename First, typename Second, typename... Args>
constexpr std::size_t pack_size_of(identity<First, Second, Args...>) noexcept {
return 2U + sizeof...(Args);
}
/// Returns an index sequence of the given type
template <typename T>
constexpr auto sequence_of(identity<T>) noexcept {
constexpr auto const size = pack_size_of(identity<T>{});
return std::make_index_sequence<size>();
}
namespace detail {
/// Calls the given unpacker with the content of the given sequenceable
template <typename U, typename F, std::size_t... I>

View File

@ -59,7 +59,7 @@ auto forward_except_last_impl(T&& tuple,
/// Forwards every element in the tuple except the last one
template <typename T>
auto forward_except_last(T&& sequenceable) {
constexpr auto const size = pack_size_of(traits::identify<T>()) - 1U;
constexpr auto const size = std::tuple_size<std::decay_t<T>>::value - 1U;
constexpr auto const sequence = std::make_index_sequence<size>();
return forward_except_last_impl(std::forward<T>(sequenceable), sequence);