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

◆ as_flat_ptr()

template<product_type Tuple>
KUMI_TRIVIAL_NODISCARD auto kumi::as_flat_ptr ( Tuple &&  ts)
noexcept

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

Parameters
tsTuple to convert
Returns
A flat tuple composed of pointers to each elements of t.

Helper type

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

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

Example

#include <kumi/tuple.hpp>
#include <iostream>
int main()
{
kumi::tuple a = { 1, kumi::tuple{ 2.3, 4.5f }, short{89} };
std::cout << a << "\n";
std::cout << ptr << "\n";
kumi::for_each([](auto ptr) { *ptr += 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.
Definition for_each.hpp:30
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