KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

◆ reverse

reverse_t kumi::reverse {}
inlineconstexprnodiscard

Callable object reversing elements of a product type.

On record types, this function operates on elements as if they were ordered. The considered order is the order of declaration.

Header file

#include <kumi/algorithm/reverse.hpp>

Call Signature

template<product_type T>
constexpr auto reverse(T && t) noexcept;
constexpr reverse_t reverse
Callable object reversing elements of a product type.
Definition reverse.hpp:78

Parameters

  • t: Product Type to reverse

Return value

  • A product type with the type of t and elements equal to (get<index<size_v<T> - 1 - Idx>>(t)...);

Helper type

template<kumi::concepts::product_type T> using reverse_t = decltype(kumi::reverse(std::declval<T>()));
template<kumi::concepts::product_type T> struct reverse
{
using type = kumi::result::reverse_t<T>;
};

Computes the return type of a call to kumi::reverse

Examples

  • Tuple
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    auto values = kumi::tuple { 1, 'a', 0.1 };
    std::cout << values << "\n";
    std::cout << kumi::reverse(values) << "\n";
    }
    Fixed-size collection of heterogeneous values.
    Definition tuple.hpp:35
  • Record
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    using namespace kumi::literals;
    auto values = kumi::record { "a"_id = 1, "b"_id = 'a', "c"_id = 0.1 };
    std::cout << values << "\n";
    std::cout << kumi::reverse(values) << "\n";
    }
    Fixed-size collection of heterogeneous tagged fields, tags are unique.
    Definition record.hpp:36