6#ifndef SL_UTILITY_TUPLE_GENERAL_HPP
7#define SL_UTILITY_TUPLE_GENERAL_HPP
25namespace sl::tuple::detail
28 template <std::
size_t index>
31 template <
class Tuple>
33 constexpr decltype(
auto)
operator ()(Tuple&& tuple)
const noexcept
36 return get<index>(std::forward<
decltype(tuple)>(tuple));
40 template <std::
size_t index>
41 inline constexpr get_fn<index>
get{};
43 template <std::
size_t index,
class Tuple>
46 using type =
decltype(get<index>(std::declval<Tuple>()));
49 template <std::
size_t index,
class Tuple>
50 using get_result_t =
typename get_result<index, Tuple>::type;
53namespace sl::concepts::detail
55 template <std::
size_t index,
class Tuple>
56 concept tuple_index = std::convertible_to<
57 tuple::detail::get_result_t<index, Tuple&>,
58 const std::tuple_element_t<index, Tuple>&>
59 && std::convertible_to<
60 tuple::detail::get_result_t<index, const Tuple&>,
61 const std::tuple_element_t<index, Tuple>&>
62 && std::convertible_to<
63 tuple::detail::get_result_t<index, Tuple&&>,
64 const std::tuple_element_t<index, Tuple>&&>
65 && std::convertible_to<
66 tuple::detail::get_result_t<index, const Tuple&&>,
67 const std::tuple_element_t<index, Tuple>&&>;
69 template <
class Tuple>
70 inline constexpr bool tuple_indices_v = []<std::size_t... indices>([[maybe_unused]] std::index_sequence<indices...>)
72 return (... && tuple_index<indices, Tuple>);
73 }(std::make_index_sequence<std::tuple_size_v<Tuple>>{});
75 template <
class Func,
class Tuple>
76 inline constexpr bool applicable_v = []<std::size_t... indices>([[maybe_unused]] std::index_sequence<indices...>)
78 return std::is_invocable_v<
80 tuple::detail::get_result_t<indices, Tuple>...>;
81 }(std::make_index_sequence<std::tuple_size_v<std::remove_cvref_t<Tuple>>>{});
83 template <
class Func,
class Tuple>
84 inline constexpr bool nothrow_applicable_v = []<std::size_t... indices>([[maybe_unused]] std::index_sequence<indices...>)
86 return std::is_nothrow_invocable_v<
88 tuple::detail::get_result_t<indices, Tuple>...>;
89 }(std::make_index_sequence<std::tuple_size_v<std::remove_cvref_t<Tuple>>>{});
104 template <
class Tuple>
106 && detail::tuple_indices_v<Tuple>;
115 template <
class Func,
class Tuple>
117 && detail::applicable_v<Func, Tuple>;
126 template <
class Func,
class Tuple>
129 && detail::nothrow_applicable_v<Func, Tuple>;
151 template <
class Func,
class Tuple>
155 using type =
decltype(std::apply(std::declval<Func>(), std::declval<Tuple>()));
164 template <
class Func,
class Tuple>
178 template <
class Tuple,
class... Others>
183 using type =
decltype(std::tuple_cat(
184 std::declval<Tuple>(),
185 std::declval<Others>()...
193 template <
class... Tuples>
Determines whether the function is invocable with the elements of the given tuple.
Definition: General.hpp:116
Determines whether the function is invocable with the elements of the given tuple without throwing.
Definition: General.hpp:127
Determines whether a type can be used as a tuple-like.
Definition: General.hpp:105
Determines whether a type satisfies the requirements of a type-list.
Definition: TypeList.hpp:103
constexpr auto get
Functional object which retrieves an object of a specific type from a tuple-like argument.
Definition: Tuple.hpp:33
typename apply_result< Func, Tuple >::type apply_result_t
Alias type determining the result of a std::apply call.
Definition: General.hpp:165
typename cat_result< Tuples... >::type tuple_cat_result_t
Alias type determining the result of a std::tuple_cat call.
Definition: General.hpp:194
Definition: operators.hpp:15
Definition: Algorithm.hpp:18
Trait type determining the result of a std::apply call.
Definition: General.hpp:154
decltype(std::apply(std::declval< Func >(), std::declval< Tuple >())) type
Definition: General.hpp:155
Trait type determining the result of a std::tuple_cat call.
Definition: General.hpp:182
decltype(std::tuple_cat(std::declval< Tuple >(), std::declval< Others >()...)) type
Definition: General.hpp:186