KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches
kumi::as_flat_ptr

Callable object converting recursively a product type of product types into a flat product type of pointers to each of its components. More...

Variables

constexpr as_flat_ptr_t kumi::as_flat_ptr {}

Detailed Description

Callable object converting recursively a product type of product types into a flat product type of pointers to each of its components.

Variable Documentation

◆ as_flat_ptr

as_flat_ptr_t kumi::as_flat_ptr {}
inlineconstexprnodiscard

On record types, the names of the outer record are concatenated to the inner ones ultimately constructing names such as "outer.inner". If the input is a product type containing record types or vice versa only the inner types matching the outer semantic will be flattened. Thus a record inside a tuple will not be flattened.

inline constexpr

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<concepts::product_type T>
constexpr auto as_flat_ptr(T && t) noexcept;
}
constexpr as_flat_ptr_t as_flat_ptr
Definition flatten.hpp:405
Main KUMI namespace.
Definition algorithm.hpp:11

Parameters

  • t: Product type to process

Return value

  • A flat product type composed of pointers to each element of t.

Helper type

template<kumi::concepts::product_type T> using as_flat_ptr_t = decltype(kumi::as_flat_ptr(kumi::declval<T>()));
template<kumi::concepts::product_type T> struct as_flat_ptr
{
using type = kumi::result::as_flat_ptr_t<T>;
};

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

Examples

  • Tuple
    #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 for_each_t for_each
    Definition for_each.hpp:141
    Fixed-size collection of heterogeneous values.
    Definition tuple.hpp:35
  • Record
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    using namespace kumi::literals;
    kumi::record a = { "a"_id = 1, "b"_id =
    kumi::record{ "c"_id = 2.3, "d"_id = 4.5f }, "e"_id = 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";
    }
    Fixed-size collection of heterogeneous fields with distinct labels.
    Definition record.hpp:36