diff --git a/include/continuable/detail/traits.hpp b/include/continuable/detail/traits.hpp index cad4b1c..29e9e4c 100644 --- a/include/continuable/detail/traits.hpp +++ b/include/continuable/detail/traits.hpp @@ -124,11 +124,6 @@ bool_constant_of(std::integral_constant /*value*/ = {}) { template using at_t = decltype(std::get(std::declval>())); -/// Evaluates to an integral constant which represents the size -/// of the given pack. -template -using size_of_t = size_constant; - /// A tagging type for wrapping other types template struct identity {}; @@ -214,28 +209,29 @@ struct apply_to_all { 0, ((void)callable(std::forward(args)), 0)...}; } }; + +/// Evaluates to the size of the given tuple like type, +// / if the type has no static size it will be one. +template +struct tuple_like_size : std::integral_constant {}; +template +struct tuple_like_size::value)>> + : std::tuple_size {}; } // namespace detail -/// Returns the pack size of the given type -template -constexpr auto pack_size_of(identity>) noexcept { - return size_of_t{}; +/// Returns the pack size of the given empty pack +constexpr auto pack_size_of(identity<>) noexcept { + return size_constant<0U>{}; } /// Returns the pack size of the given type -template -constexpr auto pack_size_of(identity>) noexcept { - return size_of_t{}; +template +constexpr auto pack_size_of(identity) noexcept { + return size_constant::value>{}; } /// Returns the pack size of the given type -template -constexpr auto pack_size_of(identity>) noexcept { - return size_constant{}; -} -/// Returns the pack size of the given type -template -constexpr auto pack_size_of(identity) noexcept { - // TODO Replace this through the generic std::tuple_size - return size_of_t{}; +template +constexpr auto pack_size_of(identity) noexcept { + return size_constant<2U + sizeof...(Args)>{}; } /// Returns an index sequence of the given type