Files
2025-10-25 03:02:53 +03:00

2.9 KiB

[pairs.spec]

22 General utilities library [utilities]

22.3 Pairs [pairs]

22.3.3 Specialized algorithms [pairs.spec]

🔗

template<class T1, class T2, class U1, class U2> constexpr bool operator==(const pair<T1, T2>& x, const pair<U1, U2>& y);

1

#

Constraints: x.first == y.first and x.second == y.second are valid expressions and each of decltype(x.first == y.first) anddecltype(x.second == y.second) models boolean-
testable
.

2

#

Returns: x.first == y.first && x.second == y.second.

🔗

template<class T1, class T2, class U1, class U2> constexpr common_comparison_category_t<synth-three-way-result<T1, U1>, synth-three-way-result<T2, U2>> operator<=>(const pair<T1, T2>& x, const pair<U1, U2>& y);

3

#

Effects: Equivalent to:if (auto c = synth-three-way(x.first, y.first); c != 0) return c;return synth-three-way(x.second, y.second);

🔗

template<class T1, class T2> constexpr void swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); template<class T1, class T2> constexpr void swap(const pair<T1, T2>& x, const pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));

4

#

Constraints:

  • (4.1)

    For the first overload,is_swappable_v is true andis_swappable_v is true.

  • (4.2)

    For the second overload,is_swappable_v is true andis_swappable_v is true.

5

#

Effects: Equivalent to x.swap(y).

🔗

template<class T1, class T2> constexpr pair<unwrap_ref_decay_t<T1>, unwrap_ref_decay_t<T2>> make_pair(T1&& x, T2&& y);

6

#

Returns: pair<unwrap_ref_decay_t, unwrap_ref_decay_t>(std::forward(x), std::forward(y))

7

#

[Example 1:

In place of:return pair<int, double>(5, 3.1415926); // explicit types a C++ program may contain:return make_pair(5, 3.1415926); // types are deduced

— end example]