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

◆ operator[]() [1/3]

template<typename... Ts>
template<typename T>
decltype(auto) kumi::record< Ts >::operator[] ( as< T > ) &
inlineconstexprnoexcept

Extracts the Ith element from a kumi::tuple.

Note
Does not participate in overload resolution if T is not present in the tuple or if the tuple contains duplicate types
Template Parameters
Tthe type to access in the tuple
Returns
A reference to the selected element of current tuple.

Example:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
kumi::record r = { "a"_id=1,"b"_id=2.3,"c"_id=4.5f, "d"_id='@' };
std::cout << r[ kumi::as<int>{} ] << "\n";
std::cout << r[ kumi::as<double>{} ] << "\n";
std::cout << r[ kumi::as<float>{} ] << "\n";
r[kumi::as<int>{}]++;
std::cout << r[kumi::as<int>{}] << "\n";
}
Lightweight type-wrapper.
Definition as.hpp:24
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29