Loading [MathJax]/extensions/tex2jax.js
kumi v3.1.0
Exquisite Epidote
 
All Classes Namespaces Functions Variables Friends Modules Pages Concepts
Loading...
Searching...
No Matches

◆ flatten_all()

template<product_type Tuple, typename Func >
constexpr auto kumi::flatten_all ( Tuple &&  ts,
Func &&  f 
)
constexpr

Recursively converts a tuple of tuples into a tuple of all elements.

Recursively converts a tuple of tuples t into a tuple of all elements of said tuples. If the Callable object f is provided, non-tuple elements are processed by f before being inserted.

Parameters
tsTuple to flatten
fOptional Callable object to apply when a sub-tuple is flattened
Returns
A tuple composed of all elements of t flattened recursively

Helper type

namespace kumi::result
{
template<product_type Tuple, typename Func = void> struct flatten_all;
template<product_type Tuple, typename Func = void>
using flatten_all_t = typename flatten_all<Tuple, Func>::type;
}
constexpr auto flatten_all(Tuple &&ts, Func &&f)
Recursively converts a tuple of tuples into a tuple of all elements.
Definition flatten.hpp:84

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

Example

#include <kumi/tuple.hpp>
#include <iostream>
int main()
{
auto nbrs = kumi::tuple{1,2ULL,3};
auto more_nbrs = kumi::tuple{short{0},nbrs,4.};
auto ltrs = kumi::tuple{'a','b','c'};
auto r = kumi::flatten_all( kumi::tuple{3.5,nbrs,'z',more_nbrs,5.35f,ltrs} );
std::cout << r << "\n";
, [](auto e) { return sizeof(e); }
);
std::cout << sz << "\n";
}
constexpr auto from_tuple(tuple< Ts... > const &t)
Converts a kumi::tuple to an instance of an arbitrary type.
Definition convert.hpp:59
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:35