Algorithms.
More...
#include <array>
#include <iostream>
#include <vector>
#include <set>
#include "concepts.hpp"
#include "pack.hpp"
#include <algorithm>
#include "static_for.hpp"
Go to the source code of this file.
|
template<typename T, typename... Formats, std::size_t N, std::size_t... Is> |
std::tuple< Formats... > | templa::algorithms::as_tuple (std::array< T, N > const &arr, std::index_sequence< Is... >) |
| Converts a fixed-size array into a tuple using specified format types.
|
template<typename T, typename... Formats, std::size_t N> |
std::tuple< Formats... > | templa::algorithms::as_tuple (std::array< T, N > const &arr) |
| Forwards array along with index sequence of the array size to the implementation.
|
template<typename T, std::size_t N, std::size_t M, std::size_t... I, std::size_t... J> |
constexpr auto | templa::algorithms::internal::concat_impl (std::array< T, N > const &lhs, std::array< T, M > const &rhs, std::index_sequence< I... >, std::index_sequence< J... >) |
template<typename T, typename O> |
void | templa::algorithms::flatten (const std::vector< T > &in, std::vector< O > &out) |
| Flattens a single-level std::vector<T> into another vector.
|
template<typename T, typename O> |
void | templa::algorithms::flatten (const std::vector< std::vector< T > > &in, std::vector< O > &out) |
| Flattens a two-level nested std::vector<std::vector<T>> into another vector.
|
◆ as_tuple() [1/2]
template<typename T, typename... Formats, std::size_t N>
std::tuple< Formats... > templa::algorithms::as_tuple |
( |
std::array< T, N > const & | arr | ) |
|
Forwards array along with index sequence of the array size to the implementation.
- Template Parameters
-
T | The element type of the input std::array. |
Formats | A parameter pack representing the target types for each tuple element. |
N | The size of the input array. |
- Parameters
-
arr | The input std::array of type T with N elements. |
◆ as_tuple() [2/2]
template<typename T, typename... Formats, std::size_t N, std::size_t... Is>
std::tuple< Formats... > templa::algorithms::as_tuple |
( |
std::array< T, N > const & | arr, |
|
|
std::index_sequence< Is... > | ) |
Converts a fixed-size array into a tuple using specified format types.
- Template Parameters
-
T | The element type of the input std::array. |
Formats | A parameter pack representing the target types for each tuple element. |
N | The size of the input array. |
Is | A parameter pack of indices used to access elements in the array. |
- Parameters
-
arr | The input std::array of type T with N elements. |
std::index_sequence<Is...> | used to unpack array indices at compile time. |
- Returns
- std::tuple<Formats...> A tuple containing elements of the array converted to the specified format types.
- Note
- The number of elements in Formats... must match the number of indices in Is....
◆ flatten() [1/2]
template<typename T, typename O>
void templa::algorithms::flatten |
( |
const std::vector< std::vector< T > > & | in, |
|
|
std::vector< O > & | out ) |
Flattens a two-level nested std::vector<std::vector<T>> into another vector.
Recursively flattens each inner vector into the output vector.
- Template Parameters
-
T | The element type of the innermost vectors. |
O | The element type of the output vector. |
- Parameters
-
in | The nested input vector to flatten. |
out | The output vector to append to. |
◆ flatten() [2/2]
template<typename T, typename O>
void templa::algorithms::flatten |
( |
const std::vector< T > & | in, |
|
|
std::vector< O > & | out ) |
Flattens a single-level std::vector<T> into another vector.
Copies elements from the input vector to the output vector using insert.
- Template Parameters
-
T | The element type of the input vector. |
O | The element type of the output vector. |
- Parameters
-
in | The input vector to flatten. |
out | The output vector to append to. |