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

◆ to_ref()

template<concepts::record_type R>
auto to_ref ( R && 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"_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";
}
constexpr auto make_record(Ts &&... ts) -> record< std::unwrap_ref_decay_t< Ts >... >
Creates a record object, deducing the target type from the types of arguments.
Definition record.hpp:396
constexpr auto to_ref(R &&r)
Creates a kumi::record of references given a reference to a kumi::record_type.
Definition record.hpp:413
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:506