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

◆ to_ref()

template<record_type Type>
constexpr auto to_ref ( Type &&  r)
related

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"_f=0,"b"_f='0',"c"_f=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";
}
constexpr decltype(auto) get(record< Ts... > &&r) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition record.hpp:395