kumi v3.1.0
Exquisite Epidote
 
Loading...
Searching...
No Matches
kumi::tuple< Ts > Class Template Reference

Fixed-size collection of heterogeneous values. More...

#include <kumi/product_types/tuple.hpp>

Detailed Description

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
TsSequence of types stored inside kumi::tuple.

Public Member Functions

template<typename Function >
constexpr auto operator() (Function &&f) const &noexcept(noexcept(kumi::apply(KUMI_FWD(f), *this))) -> decltype(kumi::apply(KUMI_FWD(f), *this))
 Invoke the Callable object f on each element of the current tuple.
 
template<typename... Us>
requires (_::piecewise_convertible<tuple, tuple<Us...>>)
constexpr tupleoperator= (tuple< Us... > &&other)
 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 (_::piecewise_convertible<tuple, tuple<Us...>>)
constexpr tupleoperator= (tuple< Us... > const &other)
 Replaces the contents of the tuple with the contents of another tuple.
 
Accessors
template<std::size_t I>
requires ( I < sizeof...(Ts) )
constexpr decltype(auto) operator[] (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[] (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[] (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[] (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 ( uniquely_typed<Ts...> && contains_type<T, Ts...> )
constexpr decltype(auto) operator[] (as< T >) &noexcept
 Extracts the Ith element from a kumi::tuple.
 
template<typename T >
requires ( uniquely_typed<Ts...> && contains_type<T, Ts...> )
constexpr decltype(auto) operator[] (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 ( uniquely_typed<Ts...> && contains_type<T, Ts...> )
constexpr decltype(auto) operator[] (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 ( uniquely_typed<Ts...> && contains_type<T, Ts...> )
constexpr decltype(auto) operator[] (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<str Name>
requires ( uniquely_named<Ts...> && contains_field<Name, Ts...> )
constexpr decltype(auto) operator[] (field_name< Name >) &noexcept
 Extracts the element labeled Name from a kumi::tuple.
 
template<str Name>
requires ( uniquely_named<Ts...> && contains_field<Name, Ts...> )
constexpr decltype(auto) operator[] (field_name< Name >) &&noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<str Name>
requires ( uniquely_named<Ts...> && contains_field<Name, Ts...> )
constexpr decltype(auto) operator[] (field_name< Name >) 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<str Name>
requires ( uniquely_named<Ts...> && contains_field<Name, Ts...> )
constexpr decltype(auto) operator[] (field_name< Name >) const &noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
Conversions
template<typename... Us>
requires ( _::piecewise_convertible<tuple, tuple<Us...>> && (sizeof...(Us) == sizeof...(Ts)) && (!std::same_as<Ts, Us> && ...) )
constexpr auto cast () const
 Converts a tuple<Ts...> to a tuple<Us...>.
 

Static Public Member Functions

Properties
static constexpr auto size () noexcept
 Returns the number of elements in a kumi::tuple.
 
static constexpr bool empty () noexcept
 Returns true if a kumi::tuple contains 0 elements.
 
static constexpr auto names () noexcept -> tuple< decltype(name_of(as< Ts >{}))... >
 Returns the names of the elements of a kumi::tuple.
 

Related Symbols

(Note that these are not member symbols.)

template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, tuple const &t) noexcept
 Inserts a kumi::tuple in an output stream.
 
Tuple construction
template<typename... Ts>
constexpr auto forward_as_tuple (Ts &&...ts) -> tuple< Ts &&... >
 Creates a kumi::tuple of forwarding references to its arguments.
 
template<product_type Type>
constexpr auto to_ref (Type &&t)
 Creates a kumi::tuple of references given a reference to a kumi::product_type.
 
Accessors
template<std::size_t I, typename... Ts>
decltype(auto) constexpr get (tuple< Ts... > &t) noexcept
 Extracts the Ith element from a kumi::tuple.
 
template<str Name, typename... Ts>
decltype(auto) constexpr get (tuple< Ts... > &t) noexcept
 Extracts the field labeled Name from a kumi::tuple if it exists.
 
template<typename T , typename... Ts>
decltype(auto) constexpr get (tuple< Ts... > &t) noexcept
 Extracts the field which type is T from a kumi::tuple if it exist.
 

Comparison operators

template<typename... Us>
requires ( equality_comparable<tuple,tuple<Us...>> )
constexpr auto operator== (tuple const &self, tuple< Us... > const &other) noexcept
 Compares a tuple with an other for equality.
 
template<typename... Us>
requires (sizeof...(Ts) == sizeof...(Us) && _::piecewise_ordered<tuple, tuple<Us...>>)
constexpr auto operator< (tuple const &lhs, tuple< Us... > const &rhs) noexcept
 Compares tuples for lexicographical is less relation.
 
template<typename... Us>
requires requires { rhs < lhs; }
constexpr auto operator<= (tuple const &lhs, tuple< Us... > const &rhs) noexcept
 Compares tuples for lexicographical is less or equal relation.
 
template<typename... Us>
requires requires { rhs < lhs; }
constexpr auto operator> (tuple const &lhs, tuple< Us... > const &rhs) noexcept
 Compares tuples for lexicographical is greater relation.
 
template<typename... Us>
requires requires { lhs < rhs; }
constexpr auto operator>= (tuple const &lhs, tuple< Us... > const &rhs) noexcept
 Compares tuples for lexicographical is greater relation relation.