Templa 0.0.1-alpha
C++ Metaprogramming Utilities
Loading...
Searching...
No Matches
templa::algorithms::reverse< elems > Struct Template Reference

Reverses a compile-time pack of constant values. More...

#include <algorithms.hpp>

Inheritance diagram for templa::algorithms::reverse< elems >:
templa::internal::uniform_element_identity< elems... >

Public Types

using identity_type = typename templa::internal::uniform_element_identity<elems...>
 The identity type wrapping the parameter pack.
using array_type = typename identity_type::uniform_type
 The array type representing the uniform values.
Public Types inherited from templa::internal::uniform_element_identity< elems... >
using uniform_type
 Type alias for the uniform std::array of elements.
using value_type
 Value type of the uniform_type.

Static Public Attributes

static constexpr auto reverse_sequence
 The reversed array, computed at compile time.
Static Public Attributes inherited from templa::internal::uniform_element_identity< elems... >
static constexpr std::size_t size
 Number of elements.
static constexpr bool valid
 Check if all elements have the same decayed type and are comparable.
static constexpr uniform_type identity_value
 Static array holding the elements.

Detailed Description

template<auto... elems>
struct templa::algorithms::reverse< elems >

Reverses a compile-time pack of constant values.

Inherits from templa::internal::uniform_element_identity to treat the pack as a uniform array, then computes a reversed version of the array at compile time.

Template Parameters
elemsA parameter pack of compile-time constant values.

Member Data Documentation

◆ reverse_sequence

template<auto... elems>
auto templa::algorithms::reverse< elems >::reverse_sequence
staticconstexpr
Initial value:
= []()
{
auto lam = []<std::size_t... I>(const array_type &in, array_type &out) constexpr
{
((out[I] = in[in.size() - I - 1]), ...);
};
std::array<int, identity_type::size> ret{};
static_for<identity_type::size>(lam, identity_type::identity_value, ret);
return ret;
}()
typename identity_type::uniform_type array_type
The array type representing the uniform values.
Definition algorithms.hpp:355

The reversed array, computed at compile time.

Constructs a new array where the order of elements is reversed relative to the input pack.


The documentation for this struct was generated from the following file: