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

◆ operator[]() [2/4]

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

Extracts the element whose identifier matches Id from a kumi::record.

Note
Does not participate in overload resolution if there are no field which identifier matches Id in the record.
Template Parameters
IdIdentifier of the element to access
Returns
A reference to the selected element 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 tagged fields, tags are unique.
Definition record.hpp:36