std::tuple_sizestd::pair - cppreference.com (original) (raw)

The partial specialization of std::tuple_size for pairs provides a compile-time way to obtain the number of elements in a pair, which is always 2, using tuple-like syntax.

[edit] Example

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 2313 C++11 specializations for pair were not required to be derived from integral_constant required

[edit] See also

Structured binding (C++17) binds the specified names to sub-objects or tuple elements of the initializer[edit]
tuple_size(C++11) obtains the number of elements of a tuple-like type (class template) [edit]
std::tuple_sizestd::array(C++11) obtains the size of an array (class template specialization) [edit]
std::tuple_sizestd::tuple(C++11) obtains the size ofa tuple (class template specialization) [edit]
std::tuple_sizestd::ranges::subrange(C++20) obtains the size of a std::ranges::subrange (class template specialization) [edit]
std::tuple_elementstd::pair(C++11) obtains the type of the elements of pair (class template specialization) [edit]