KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

◆ operator[]() [1/4]

template<typename... Ts>
decltype(auto) kumi::tuple< Ts >::operator[] ( Id const & ) &
inlineconstexprnoexcept

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

Note
Does not participate in overload resolution if no field whose identifier matches Id is present in the tuple or if the tuple contains duplicate identifiers.
Template Parameters
IdIdentifier of the element to access
Returns
A reference to the selected element of current tuple.

Example:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
kumi::tuple t = { "x"_id = 1, "y"_id = 2.3, "z"_id = 4.5f, "t"_id = '@' };
std::cout << t << "\n";
std::cout << t["x"_id] << "\n";
std::cout << t["y"_id] << "\n";
std::cout << t["z"_id] << "\n";
t["t"_id]++;
std::cout << t["t"_id] << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:35