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

◆ to_ref() [1/2]

template<concepts::record_type R>
auto kumi::to_ref ( R && r)
inlinenodiscardconstexpr

Creates a kumi::record of references given a reference to a kumi::record_type.

Parameters
rRecord whose elements are to be referenced.
Returns
A record equivalent to the result of kumi::apply([]<typename... T>(T&&... e) { return kumi::forward_as_record<name_of(as<T>{})...>(std::forward<T>(e)...); }, t)

Example:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto original = kumi::make_record("a"_id=0,"b"_id='0',"c"_id=0.f);
auto ref = kumi::to_ref( original );
std::cout << original << "\n";
kumi::get<"a">(ref) = 9;
kumi::get<"b">(ref) = 'z';
kumi::get<"c">(ref) = 3.14159f;
std::cout << original << "\n";
}
decltype(auto) constexpr get(record< Ts... > &r) noexcept
Extracts the Ith field from a kumi::record.
Definition record.hpp:604