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

◆ operator[]() [3/3]

template<typename... Ts>
template<concepts::identifier Name>
decltype(auto) kumi::record< Ts >::operator[] ( Name const & ) &
inlineconstexprnoexcept

Extracts the element of the field labeled Name from a kumi::record.

Note
Does not participate in overload resolution if the name is not present in the record
Template Parameters
NameNon type template parameter name of the field to access
Returns
A reference to the element of 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 << "\n";
std::cout << r["x"_id] << "\n";
std::cout << r["y"_id] << "\n";
std::cout << r["z"_id] << "\n";
r["t"_id]++;
std::cout << r["t"_id] << "\n";
}
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29