6#ifndef SL_UTILITY_FUNCTIONAL_TUPLE_HPP
7#define SL_UTILITY_FUNCTIONAL_TUPLE_HPP
33 inline constexpr auto get = envelop<Transform>(
34 []<
class Tuple>(Tuple&& v) ->
decltype(
auto)
requires concepts::tuple<std::remove_cvref_t<Tuple>>
37 return get<T>(std::forward<Tuple>(v));
44 template <std::
size_t index>
45 inline constexpr auto get_at = envelop<Transform>(
46 []<
class Tuple>(Tuple&& v) ->
decltype(
auto)
requires concepts::tuple<std::remove_cvref_t<Tuple>>
49 return get<index>(std::forward<Tuple>(v));
53namespace sl::functional::tuple::detail
57 template <
class... Args,
class Tuple>
59 constexpr std::tuple<Args...>
reduce(Tuple&& tuple)
61 return {tuple::get<Args>(std::forward<Tuple>(tuple))...};
66 template <
class... Tuples>
67 requires (... && concepts::tuple<std::remove_cvref_t<Tuples>>)
68 constexpr auto concat(Tuples&&... tuples)
70 return std::tuple_cat(std::forward<Tuples>(tuples)...);
81 template <
class... Args>
82 requires concepts::unique_types<Args...>
83 inline constexpr auto reduce = envelop<Transform>(
84 []<
class Tuple>(Tuple&& t)
87 return detail::reduce<Args...>(std::forward<Tuple>(t));
93 inline constexpr auto concat = envelop<Transform>(
94 []<
class... Tuples>(Tuples&&... tuples)
97 return detail::concat(std::forward<Tuples>(tuples)...);
103 inline constexpr auto tie = envelop<Transform>(
104 [](
auto&... args) {
return std::tie(args...); });
111 []<
class Tuple>(Tuple&& t)
noexcept(
noexcept(std::make_from_tuple<To>(std::forward<Tuple>(t))))
116 requires { { std::make_from_tuple<To>(std::forward<Tuple>(t)) }; },
117 "The object is not constructible with the elements of the given tuple.");
119 std::same_as<To, decltype(std::make_from_tuple<To>(std::declval<Tuple>()))>,
120 "The object is not constructible with the elements of the given tuple.");
122 return std::make_from_tuple<To>(std::forward<Tuple>(t));
136 template <function Fn>
The core class, wrapping one functional object and enabling a variety of composing operators for it.
Definition: BasicClosure.hpp:112
Determines whether a type can be used as a tuple-like.
Definition: General.hpp:105
constexpr auto make_from
Constructs an object with elements from the source tuple as constructor arguments.
Definition: Tuple.hpp:110
constexpr auto get
Functional object which retrieves an object of a specific type from a tuple-like argument.
Definition: Tuple.hpp:33
constexpr auto concat
Combines all elements from each given tuple into one tuple.
Definition: Tuple.hpp:93
constexpr auto get_at
Functional object which retrieves an object at a specific index from a tuple-like argument.
Definition: Tuple.hpp:45
constexpr auto reduce
Reduces (or permutes) the components of a tuple and returns a them as new tuple.
Definition: Tuple.hpp:83
constexpr auto tie
Combines all given lvalue references into one tuple.
Definition: Tuple.hpp:103
Definition: Arithmetic.hpp:13