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

◆ as_flat_ptr()

template<product_type T>
auto kumi::as_flat_ptr ( T &&  t)
inlinenoexcept

Convert a kumi::product_type to a flat product type of pointers to each its components.

Parameters
tProduct type to convert
Returns
A flat product_type composed of pointers to each elements of t.

Helper type

namespace kumi::result
{
template<product_type T> struct as_flat_ptr;
template<product_type T>
using as_flat_ptr_t = typename as_flat_ptr<T>::type;
}
auto as_flat_ptr(T &&t) noexcept
Convert a kumi::product_type to a flat product type of pointers to each its components.
Definition flatten.hpp:264

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

Example

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
kumi::tuple a = { 1, kumi::tuple{ 2.3, 4.5f }, short{89} };
auto ptr = kumi::as_flat_ptr(a);
std::cout << a << "\n";
std::cout << ptr << "\n";
kumi::for_each([](auto p) { *p += 5; }, ptr );
std::cout << a << "\n";
}
constexpr void for_each(Function f, Tuple &&t, Tuples &&... ts)
Applies the Callable object f on each element of a kumi::product_type. f is applied on the values if ...
Definition for_each.hpp:32
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:37