Namespaces
Variants
Views
Actions

tuple-like, pair-like

From cppreference.com
< cpp‎ | utility‎ | tuple
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)
 
 
template< class B >
concept tuple-like = /* see below */; // exposition only
(since C++23)
template< class B >

concept pair-like =                   // exposition only

    tuple-like<T> && std::tuple_size_v<std::remove_cvref_t<T>> == 2;
(since C++23)

A type T models and satisfies the exposition-only concept tuple-like if std::remove_cvref_t<T> is a specialization of std::array, std::pair, std::tuple, or std::ranges::subrange.

pair-like objects are tuple-like objects with exactly 2 elements.

[edit] Notes

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.

[edit] See also

tuple-like and pair-like are used in the following standard library components:

constructs a new tuple
(public member function) [edit]
(C++11)
assigns the contents of one tuple to another
(public member function) [edit]
(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) [edit]
determines the common reference type of a tuple and a tuple-like type
(class template specialization) [edit]
determines the common type of a tuple and a tuple-like type
(class template specialization) [edit]
(C++11)
creates a tuple by concatenating any number of tuples
(function template) [edit]
(C++17)
calls a function with a tuple of arguments
(function template) [edit]
Construct an object with a tuple of arguments
(function template) [edit]
constructs new pair
(public member function of std::pair<T1,T2>) [edit]
assigns the contents
(public member function of std::pair<T1,T2>) [edit]
converts the subrange to a pair-like type
(public member function of std::ranges::subrange<I,S,K>) [edit]
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) [edit]