Files
cppdraft_translate/cppdraft/depr/relops.md
2025-10-25 03:02:53 +03:00

89 lines
3.1 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[depr.relops]
# Annex D (normative) Compatibility features [[depr]](./#depr)
## D.14 Relational operators [depr.relops]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L444)
The header [<utility>](utility.syn#header:%3cutility%3e "22.2.1Header <utility> synopsis[utility.syn]") has the following additions:
namespace std::rel_ops {template<class T> bool operator!=(const T&, const T&); template<class T> bool operator> (const T&, const T&); template<class T> bool operator<=(const T&, const T&); template<class T> bool operator>=(const T&, const T&);}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L456)
To avoid redundant definitions of operator!= out of operator== and operators >, <=, and >= out of operator<,
the library provides the following:
[🔗](#lib:operator!=)
`template<class T> bool operator!=(const T& x, const T& y);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L467)
*Preconditions*: T meets the *Cpp17EqualityComparable* requirements (Table [28](utility.arg.requirements#tab:cpp17.equalitycomparable "Table 28: Cpp17EqualityComparable requirements"))[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L471)
*Returns*: !(x == y)[.](#4.sentence-1)
[🔗](#lib:operator%3e)
`template<class T> bool operator>(const T& x, const T& y);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L482)
*Preconditions*: T meets the *Cpp17LessThanComparable* requirements (Table [29](utility.arg.requirements#tab:cpp17.lessthancomparable "Table 29: Cpp17LessThanComparable requirements"))[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L486)
*Returns*: y < x[.](#6.sentence-1)
[🔗](#lib:operator%3c=)
`template<class T> bool operator<=(const T& x, const T& y);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L497)
*Preconditions*: T meets the *Cpp17LessThanComparable* requirements (Table [29](utility.arg.requirements#tab:cpp17.lessthancomparable "Table 29: Cpp17LessThanComparable requirements"))[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L501)
*Returns*: !(y < x)[.](#8.sentence-1)
[🔗](#lib:operator%3e=)
`template<class T> bool operator>=(const T& x, const T& y);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L512)
*Preconditions*: T meets the *Cpp17LessThanComparable* requirements (Table [29](utility.arg.requirements#tab:cpp17.lessthancomparable "Table 29: Cpp17LessThanComparable requirements"))[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L516)
*Returns*: !(x < y)[.](#10.sentence-1)