Sequoia
Loading...
Searching...
No Matches
Functions
ArrayUtilities.hpp File Reference

Utility to convert an initializer_list into an array, potentially transforming the initializer_list in the process. More...

#include <array>
#include <span>
#include <string>
#include <stdexcept>
#include <type_traits>
#include <utility>

Go to the source code of this file.

Functions

template<class T , class InitType , class Fn >
requires std::is_invocable_r_v<T, Fn, InitType>
constexpr T sequoia::utilities::impl::to_element (std::initializer_list< InitType > l, const std::size_t i, Fn fn)
 
template<class T , std::size_t N, class InitType , std::size_t... I, class Fn >
requires std::is_invocable_r_v<T, Fn, InitType>
constexpr std::array< T, N > sequoia::utilities::impl::to_array (std::initializer_list< InitType > l, std::index_sequence< I... >, Fn &&fn)
 
template<class T , std::size_t N, class InitType = T, class Fn = std::identity>
requires std::is_invocable_r_v<T, Fn, InitType>
constexpr std::array< T, N > sequoia::utilities::to_array (std::initializer_list< InitType > l, Fn fn=Fn{})
 
template<class T , std::size_t N, class Fn >
requires std::is_invocable_r_v<T, Fn, std::size_t>
constexpr std::array< T, N > sequoia::utilities::make_array (Fn f)
 
template<class T , std::size_t N, class Fn = std::identity>
requires std::is_invocable_r_v<T, Fn, T>
constexpr std::array< T, N > sequoia::utilities::to_array (std::span< const T, N > data, Fn f={})
 

Detailed Description

Utility to convert an initializer_list into an array, potentially transforming the initializer_list in the process.

Function Documentation

◆ make_array()

template<class T , std::size_t N, class Fn >
requires std::is_invocable_r_v<T, Fn, std::size_t>
constexpr std::array< T, N > sequoia::utilities::make_array ( Fn  f)
constexpr

Generates an array of size N, formed by applying the function, f, to the indices generated by std::make_index_sequence<N>

◆ to_array()

template<class T , std::size_t N, class Fn = std::identity>
requires std::is_invocable_r_v<T, Fn, T>
constexpr std::array< T, N > sequoia::utilities::to_array ( std::span< const T, N >  data,
Fn  f = {} 
)
constexpr

Generates an array of size N, formed by applying the function, f, to the elements of the span.