# <utility> <utility> # `` * * * **`make_pair· operator!==· operator==· operator<· operator<=· operator>· operator>=· pair`** * * * Include the [STL](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#STL) standard header **``** to define several templates of general use throughout the Standard Template Library. Four template operators -- `operator!=`, `operator<=`, `operator>`, and `operator>=` -- define a **total ordering** on pairs of operands of the same type, given definitions of `operator==` and `operator<`. If an [implementation](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#implementation) supports namespaces, these template operators are defined in the **`rel_ops`** namespace, nested within the `std` namespace. If you wish to make use of these template operators, write the declaration: using namespace std::rel_ops;Copy to clipboard which promotes the template operators into the current namespace. namespace std { template struct pair; // TEMPLATE FUNCTIONS template pair make_pair(Ty1 val1, Ty2 val2); template bool operator==(const pair& left, const pair& right); template bool operator!=(const pair& left, const pair& right); template bool operator<(const pair& left, const pair& right); template bool operator>(const pair& left, const pair& right); template bool operator<=(const pair& left, const pair& right); template bool operator>=(const pair& left, const pair& right); namespace rel_ops { template bool operator!=(const Ty& left, const Ty& right); template bool operator<=(const Ty& left, const Ty& right); template bool operator>(const Ty& left, const Ty& right); template bool operator>=(const Ty& left, const Ty& right); } // namespace rel_ops } // namespace stdCopy to clipboard ## `make_pair` template pair make_pair(Ty1 val1, Ty2 val2);Copy to clipboard The template function returns `pair(val1, val2)`. ## `operator!=` template bool operator!=(const Ty& left, const Ty& right); template bool operator!=(const pair& left, const pair& right);Copy to clipboard The template function returns `!(left == right)`. ## `operator==` template bool operator==(const pair& left, const pair& right);Copy to clipboard The template function returns `left.first == right.first && left.second == right.second`. ## `operator<` template bool operator<(const pair& left, const pair& right);Copy to clipboard The template function returns `left.first < right.first || !(right.first < left.first) && left.second < right.second`. ## `operator<=` template bool operator<=(const Ty& left, const Ty& right); template bool operator<=(const pair& left, const pair& right);Copy to clipboard The template function returns `!(right < left)`. ## `operator>` template bool operator>(const Ty& left, const Ty& right); template bool operator>(const pair& left, const pair& right);Copy to clipboard The template function returns `right < left`. ## `operator>=` template bool operator>=(const Ty& left, const Ty& right); template bool operator>=(const pair& left, const pair& right);Copy to clipboard The template function returns `!(left < right)`. ## `pair` template struct pair { typedef Ty1 first_type; typedef Ty2 second_type Ty1 first; Ty2 second; pair(); pair(const Ty1& val1, const Ty2& val2); template pair(const pair& right); };Copy to clipboard The template class stores a pair of objects, **`first`**, of type `Ty1`, and **`second`**, of type `Ty2`. The type definition **`first_type`**, is the same as the template parameter `Ty1`, while **`second_type`**, is the same as the template parameter `Ty2`. The first (default) constructor initializes `first` to `Ty1()` and `second` to `Ty2()`. The second constructor initializes `first` to `val1` and `second` to `val2`. The third (template) constructor initializes `first` to `right.first` and `second` to `right.second`. `Ty1` and `Ty2` each need supply only a default constructor, single-argument constructor, and a destructor. * * * See also the **[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#Table%20of%20Contents)** and the **[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_cpp_index.html)**. *[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_pjp.html) © 1992-2006by P.J. Plauger. Portions derived from work[copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_hp.html) © 1994by Hewlett-Packard Company. All rights reserved.* Last Published: Oct 06, 2026 Previous Topic Next Topic