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

◆ operator[]()

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

Extracts the Ith element from a kumi::tuple.

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

Example:

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