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

◆ get() [3/3]

template<std::size_t I, typename... Ts>
decltype(auto) constexpr get ( record< Ts... > & r)
related

Extracts the Ith field from a kumi::record.

Note
Does not participate in overload resolution if I is not in [0, sizeof...(Ts)).
Template Parameters
ICompile-time index of the field to access
Parameters
rRecord to index
Returns
A reference to the selected field of r.

Example:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
kumi::record r = { "x"_id = 1, "y"_id = 2.3, "z"_id = 4.5f, "t"_id = '@' };
std::cout << kumi::get<0>(r) << "\n";
std::cout << kumi::get<1>(r) << "\n";
std::cout << kumi::get<2>(r) << "\n";
kumi::get<3>(r).value++;
std::cout << kumi::get<3>(r) << "\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:506
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29