kumi v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches

◆ flatten()

template<concepts::product_type T>
auto kumi::flatten ( T && t)
inlinenodiscardconstexpr

Converts a product type of product types into a product type of all elements.

Parameters
tProduct type to flatten
Returns
A product type composed of all elements of t flattened non-recursively
Note
There is a semantic difference between record and tuples flattening.

Helper type

namespace kumi::result
{
template<product_type T> struct flatten;
template<product_type T>
using flatten_t = typename flatten<T>::type;
}
constexpr auto flatten(T &&t)
Converts a product type of product types into a product type of all elements.
Definition flatten.hpp:110

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

Examples:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto nbrs = kumi::tuple{1,2,3};
auto more_nbrs = kumi::tuple{0,nbrs,4};
auto ltrs = kumi::tuple{'a','b','c'};
auto r = kumi::flatten( kumi::tuple{3.5,nbrs,'z',more_nbrs,5.35f,ltrs} );
std::cout << r << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:29
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto nbrs = kumi::record{"a"_id = 1,"b"_id = 2,"c"_id = 3};
auto more_nbrs = kumi::record{"a"_id = 0,"b"_id = nbrs,"c"_id = 4};
auto ltrs = kumi::record{"a"_id = 'a',"b"_id = 'b',"c"_id = 'c'};
auto r = kumi::flatten( kumi::record{"a"_id = 3.5,"b"_id = nbrs,"c"_id = 'z'
,"d"_id = more_nbrs,"e"_id = 5.35f,"f"_id = ltrs} );
std::cout << r << "\n";
}
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29