template<typename... Ts>
class kumi::tuple< Ts >
Fixed-size collection of heterogeneous values.
kumi::tuple provides an aggregate based implementation of a tuple. It provides algorithms and functions designed to facilitate tuple's handling and transformations.
kumi::tuple is also compatible with standard tuple operations and structured bindings.
- Template Parameters
-
- See also
- Product Type
Example:
#include <iostream>
#include <stdexcept>
#include <string>
#include <kumi/kumi.hpp>
{
switch (id)
{
case 0: return {3.8, 'A', "Lisa Simpson"};
case 1: return {2.9, 'C', "Milhouse Van Houten"};
case 2: return {1.7, 'D', "Ralph Wiggum"};
case 3: return {0.6, 'F', "Bart Simpson"};
}
throw std::invalid_argument("id");
}
int main()
{
const auto student0 = get_student(0);
std::cout << "ID: 0, "
const auto student1 = get_student(1);
std::cout << "ID: 1, "
double gpa2;
char grade2;
std::string name2;
kumi::tie(gpa2, grade2, name2) = get_student(2);
std::cout << "ID: 2, "
<< "GPA: " << gpa2 << ", "
<< "grade: " << grade2 << ", "
<< "name: " << name2 << '\n';
const auto [gpa3, grade3, name3] = get_student(3);
std::cout << "ID: 3, "
<< "GPA: " << gpa3 << ", "
<< "grade: " << grade3 << ", "
<< "name: " << name3 << '\n';
}
constexpr tie_t tie
Definition tuple.hpp:540
decltype(auto) constexpr get(array< T, N > &t) noexcept
Extracts the Ith element from a kumi::array.
Definition array.hpp:672
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:35
|
template<typename... Us>
requires (sizeof...(Ts) == sizeof...(Us)) && ((std::is_assignable_v<Ts&, Us&&> && ...)) |
| constexpr tuple & | operator= (tuple< Us... > &&other) noexcept((std::is_nothrow_assignable_v< Ts &, Us && > &&...)) |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename... Us>
requires (sizeof...(Ts) == sizeof...(Us)) && ((std::is_assignable_v<Ts&, Us const&> && ...)) |
| constexpr tuple & | operator= (tuple< Us... > const &other) noexcept((std::is_nothrow_assignable_v< Ts &, Us const & > &&...)) |
| | Replaces the contents of the tuple with the contents of another tuple.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I > i) &noexcept |
| | Extracts the Ith element from a kumi::tuple.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I >) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I >) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I >) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<Ts...> && kumi::concepts::contains_type<T, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T > type) &noexcept |
| | Extracts the element with type T from a kumi::tuple.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<Ts...> && kumi::concepts::contains_type<T, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T >) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<Ts...> && kumi::concepts::contains_type<T, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T >) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<Ts...> && kumi::concepts::contains_type<T, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T >) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::str L>
requires (kumi::concepts::contains_label<kumi::label_t<L>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< L > s) &noexcept |
| | Extracts the element of the field labeled L from a kumi::tuple.
|
template<kumi::str L>
requires (kumi::concepts::contains_label<kumi::label_t<L>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< L >) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::str L>
requires (kumi::concepts::contains_label<kumi::label_t<L>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< L >) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::str L>
requires (kumi::concepts::contains_label<kumi::label_t<L>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< L >) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::uniquely_named<Ts...> && kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) &noexcept |
| | Extracts the element whose identifier matches Id from a kumi::tuple.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::uniquely_named<Ts...> && kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::uniquely_named<Ts...> && kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::uniquely_named<Ts...> && kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename... Us>
requires (sizeof...(Us) == sizeof...(Ts)) && (!std::same_as<tuple<Ts...>, tuple<Us...>>) && ((std::is_constructible_v<Us, Ts const&> && ...)) |
| | explicit (!(std::is_convertible_v< Ts const &, Us > &&...)) const expr operator tuple< Us... >() const noexcept((std::is_nothrow_constructible_v< Us, Ts const & > &&...)) |
| | Enables static casting a tuple<Ts...> to a tuple<Us...>, the conversion is explicit if the casting requires internal explicit conversions.
|
template<typename... Us>
requires (sizeof...(Us) == sizeof...(Ts)) && (!std::same_as<tuple<Ts...>, tuple<Us...>>) && ((std::is_constructible_v<Us, Ts&> && ...)) |
| | explicit (!(std::is_convertible_v< Ts &, Us > &&...)) const expr operator tuple< Us... >() noexcept((std::is_nothrow_constructible_v< Us, Ts & > &&...)) |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
|
(Note that these are not member symbols.)
|
|
template<typename CharT, typename Traits, typename... Ts> |
| std::basic_ostream< CharT, Traits > & | operator<< (std::basic_ostream< CharT, Traits > &os, tuple< Ts... > const &t) noexcept |
| | Inserts a kumi::tuple in an output stream.
|
|
template<typename... Ts, typename... Us> |
| constexpr auto | operator== (tuple< Ts... > const &self, tuple< Us... > const &other) noexcept |
| | Compares a tuple with another for equality.
|
|
template<typename... Ts, typename... Us> |
| constexpr auto | operator!= (tuple< Ts... > const &self, tuple< Us... > const &other) noexcept |
| | Compares a tuple with another for inequality.
|
| template<typename... Ts, typename... Us> |
| constexpr auto | operator< (tuple< Ts... > const &lhs, tuple< Us... > const &rhs) noexcept |
| | Compares tuples for the lexicographical less-than relation.
|
|
template<typename... Ts, typename... Us> |
| constexpr auto | operator<= (tuple< Ts... > const &lhs, tuple< Us... > const &rhs) noexcept |
| | Compares tuples for the lexicographical less-than-or-equal relation.
|
|
template<typename... Ts, typename... Us> |
| constexpr auto | operator> (tuple< Ts... > const &lhs, tuple< Us... > const &rhs) noexcept |
| | Compares tuples for the lexicographical greater-than relation.
|
|
template<typename... Ts, typename... Us> |
| constexpr auto | operator>= (tuple< Ts... > const &lhs, tuple< Us... > const &rhs) noexcept |
| | Compares tuples for the lexicographical greater-than-or-equal relation.
|
| template<typename... Ts> |
| | tuple (Ts &&...) -> tuple< std::unwrap_ref_decay_t< Ts >... > |
| | kumi::tuple deduction guide
|
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &t) noexcept |
| | Extracts the Ith element from a kumi::tuple.
|
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &&arg) noexcept |
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &arg) noexcept |
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &&arg) noexcept |
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &t) noexcept |
| | Extracts the field labeled L from a kumi::tuple if it exists.
|
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &&t) noexcept |
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &t) noexcept |
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &&t) noexcept |
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &t) noexcept |
| | Extracts the field identified by Id from a kumi::tuple if it exists.
|
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &&t) noexcept |
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &t) noexcept |
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &&t) noexcept |
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &t) noexcept |
| | Extracts the field whose type is T from a kumi::tuple if it exists.
|
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > &&t) noexcept |
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &t) noexcept |
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (tuple< Ts... > const &&t) noexcept |