template< class T > concept tuple-like = /* see below */; // exposition only | (1) | (since C++23) |
template< class T > concept pair-like = // exposition only tuple-like<T> && std::tuple_size_v<std::remove_cvref_t<T>> == 2; | (2) | (since C++23) |
std::remove_cvref_t<T>
pair-like
objects are tuple-like
objects with exactly 2 elements.tuple-like
types implement the tuple protocol, i.e., such types can be used with std::get
, std::tuple_element
and std::tuple_size
.
Elements of tuple-like
types can be bound with structured binding.
tuple-like
and pair-like
are used in the following standard library components:
(C++11) | constructs a new tuple (public member function) |
(C++11) | assigns the contents of one tuple to another (public member function) |
(removed in C++20)(removed in C++20)(removed in C++20)(removed in C++20)(removed in C++20)(C++20) | lexicographically compares the values in the tuple (function template) |
(C++23) | determines the common reference type of a tuple and a tuple-like type (class template specialization) |
(C++23) | determines the common type of a tuple and a tuple-like type (class template specialization) |
(C++11) | creates a tuple by concatenating any number of tuples (function template) |
(C++17) | calls a function with a tuple of arguments (function template) |
(C++17) | construct an object with a tuple of arguments (function template) |
constructs new pair (public member function of std::pair<T1,T2> ) |
|
assigns the contents (public member function of std::pair<T1,T2> ) |
|
(C++20) | converts the subrange to a pair-like type (public member function of std::ranges::subrange<I,S,K> ) |
(C++20) | takes a view consisting of tuple-like values and a number N and produces a view of N'th element of each tuple (class template) (range adaptor object) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/utility/tuple/tuple-like