Recursively converts a product type of product types into a product type of all elements.
Recursively converts a product type of product types t into a product type of all elements of said product types.
If the Callable object f is provided, non-product type elements are processed by f before being inserted.
- Note
- There is a semantic difference between record and tuples flattening.
- Parameters
-
| t | Product type to flatten |
| f | Optional 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 T,
typename Func =
void>
struct flatten_all;
template<product_type T, typename Func = void>
}
constexpr auto flatten_all(T &&t, Func f)
Recursively converts a product type of product types into a product type of all elements.
Definition flatten.hpp:160
Computes the return type of a call to kumi::flatten_all
Examples:
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
std::cout << r << "\n";
, [](auto e) { return sizeof(e); }
);
std::cout << sz << "\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{
"f"_id = 1,
"s"_id = 2ULL,
"t"_id = 3};
auto more_nbrs =
kumi::record{
"z"_id =
short{0},
"n"_id = nbrs,
"l"_id = 4.};
auto ltrs =
kumi::record{
"alpha"_id =
'a',
"beta"_id =
'b',
"gamma"_id =
'c'};
,"d"_id = more_nbrs,"e"_id = 5.35f,"f"_id = ltrs} );
std::cout << r << "\n";
,"d"_id = more_nbrs,"e"_id = 5.35f,"f"_id = ltrs}
, [](auto e) { return sizeof(e); }
);
std::cout << sz << "\n";
}
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29