tuple-like, pair-like - cppreference.com
Namespaces
Variants

tuple-like, pair-like

From cppreference.com
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
 
template< class T >
concept tuple-like = /* see below */;
(1) (since C++23)
(exposition only*)
template< class T >
concept pair-like =
    tuple-like<T> && std::tuple_size_v<std::remove_cvref_t<T>> == 2;
(2) (since C++23)
(exposition only*)
1) A type T models and satisfies the concept tuple-like if std::remove_cvref_t<T> is a specialization of
  • std::array,
  • std::complex,
(since C++26)
  • std::pair,
  • std::tuple, or
  • std::ranges::subrange.
2) pair-like objects are tuple-like objects with exactly 2 elements.

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.

See also

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