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

◆ operator[]() [3/4]

template<typename... Ts>
template<std::size_t I>
requires (I < sizeof...(Ts))
decltype(auto) kumi::record< Ts >::operator[] ( index_t< I > i) &
inlineconstexprnoexcept

Extracts the Ith field from a kumi::record.

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

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 << r[0_c] << "\n";
std::cout << r[1_c] << "\n";
std::cout << r[2_c] << "\n";
r[3_c].value++;
std::cout << r[kumi::index<3>] << "\n";
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36