Skip to content

Commit c9d19d1

Browse files
CaseyCarterzygoloid
authored andcommitted
Order library comparisons canonically
The order [==, !=, <, >, <=, >=] seems to be most common. Let's make it canonical and use it uniformly.
1 parent 78a0026 commit c9d19d1

File tree

11 files changed

+367
-367
lines changed

11 files changed

+367
-367
lines changed

source/containers.tex

Lines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.

source/diagnostics.tex

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,6 @@
887887
error_condition make_error_condition(errc e) noexcept;
888888

889889
// \ref{syserr.compare}, comparison functions
890-
bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
891-
bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
892890
bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
893891
bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;
894892
bool operator==(const error_condition& lhs, const error_code& rhs) noexcept;
@@ -897,6 +895,8 @@
897895
bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept;
898896
bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept;
899897
bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept;
898+
bool operator< (const error_code& lhs, const error_code& rhs) noexcept;
899+
bool operator< (const error_condition& lhs, const error_condition& rhs) noexcept;
900900

901901
// \ref{syserr.hash}, hash support
902902
template<class T> struct hash;
@@ -957,7 +957,7 @@
957957

958958
bool operator==(const error_category& rhs) const noexcept;
959959
bool operator!=(const error_category& rhs) const noexcept;
960-
bool operator<(const error_category& rhs) const noexcept;
960+
bool operator< (const error_category& rhs) const noexcept;
961961
};
962962

963963
const error_category& generic_category() noexcept;
@@ -1549,34 +1549,6 @@
15491549

15501550
\rSec2[syserr.compare]{Comparison functions}
15511551

1552-
\indexlibrarymember{operator<}{error_code}%
1553-
\begin{itemdecl}
1554-
bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
1555-
\end{itemdecl}
1556-
1557-
\begin{itemdescr}
1558-
\pnum
1559-
\returns
1560-
\begin{codeblock}
1561-
lhs.category() < rhs.category() ||
1562-
(lhs.category() == rhs.category() && lhs.value() < rhs.value())
1563-
\end{codeblock}
1564-
\end{itemdescr}
1565-
1566-
\indexlibrarymember{operator<}{error_condition}%
1567-
\begin{itemdecl}
1568-
bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
1569-
\end{itemdecl}
1570-
1571-
\begin{itemdescr}
1572-
\pnum
1573-
\returns
1574-
\begin{codeblock}
1575-
lhs.category() < rhs.category() ||
1576-
(lhs.category() == rhs.category() && lhs.value() < rhs.value())
1577-
\end{codeblock}
1578-
\end{itemdescr}
1579-
15801552
\indexlibrarymember{operator==}{error_code}%
15811553
\begin{itemdecl}
15821554
bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
@@ -1645,6 +1617,34 @@
16451617
\returns \tcode{!(lhs == rhs)}.
16461618
\end{itemdescr}
16471619

1620+
\indexlibrarymember{operator<}{error_code}%
1621+
\begin{itemdecl}
1622+
bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
1623+
\end{itemdecl}
1624+
1625+
\begin{itemdescr}
1626+
\pnum
1627+
\returns
1628+
\begin{codeblock}
1629+
lhs.category() < rhs.category() ||
1630+
(lhs.category() == rhs.category() && lhs.value() < rhs.value())
1631+
\end{codeblock}
1632+
\end{itemdescr}
1633+
1634+
\indexlibrarymember{operator<}{error_condition}%
1635+
\begin{itemdecl}
1636+
bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
1637+
\end{itemdecl}
1638+
1639+
\begin{itemdescr}
1640+
\pnum
1641+
\returns
1642+
\begin{codeblock}
1643+
lhs.category() < rhs.category() ||
1644+
(lhs.category() == rhs.category() && lhs.value() < rhs.value())
1645+
\end{codeblock}
1646+
\end{itemdescr}
1647+
16481648
\rSec2[syserr.hash]{System error hash support}
16491649

16501650
\indexlibrary{\idxcode{hash}!\idxcode{error_code}}%

source/iostreams.tex

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12735,81 +12735,81 @@
1273512735
for two paths, \tcode{p1 == p2} then \tcode{hash_value(p1) == hash_value(p2)}.
1273612736
\end{itemdescr}
1273712737

12738-
\indexlibrarymember{operator<}{path}%
12738+
\indexlibrarymember{operator==}{path}%
1273912739
\begin{itemdecl}
12740-
bool operator< (const path& lhs, const path& rhs) noexcept;
12740+
bool operator==(const path& lhs, const path& rhs) noexcept;
1274112741
\end{itemdecl}
1274212742

1274312743
\begin{itemdescr}
1274412744
\pnum
12745-
\returns \tcode{lhs.compare(rhs) < 0}.
12745+
\returns \tcode{!(lhs < rhs) \&\& !(rhs < lhs)}.
12746+
12747+
\indextext{path equality}
12748+
\pnum
12749+
\begin{note} Path equality and path equivalence have different semantics.
12750+
\begin{itemize}
12751+
\item Equality is determined by the \tcode{path} non-member \tcode{operator==},
12752+
which considers the two paths' lexical representations only.
12753+
\begin{example} \tcode{path("foo") == "bar"} is never \tcode{true}. \end{example}
12754+
\item Equivalence is determined by the \tcode{equivalent()} non-member function, which
12755+
determines if two paths resolve\iref{fs.class.path} to the same file system entity.
12756+
\begin{example}
12757+
\tcode{equivalent("foo", "bar")} will be \tcode{true} when both paths resolve to the same file.
12758+
\end{example}
12759+
\end{itemize}
12760+
Programmers wishing to determine if two paths are ``the same'' must decide if
12761+
``the same'' means ``the same representation'' or ``resolve to the same actual
12762+
file'', and choose the appropriate function accordingly. \end{note}
1274612763
\end{itemdescr}
1274712764

12748-
\indexlibrarymember{operator<=}{path}%
12765+
\indexlibrarymember{operator"!=}{path}%
1274912766
\begin{itemdecl}
12750-
bool operator<=(const path& lhs, const path& rhs) noexcept;
12767+
bool operator!=(const path& lhs, const path& rhs) noexcept;
1275112768
\end{itemdecl}
1275212769

1275312770
\begin{itemdescr}
1275412771
\pnum
12755-
\returns \tcode{!(rhs < lhs)}.
12772+
\returns \tcode{!(lhs == rhs)}.
1275612773
\end{itemdescr}
1275712774

12758-
\indexlibrarymember{operator>}{path}%
12775+
\indexlibrarymember{operator<}{path}%
1275912776
\begin{itemdecl}
12760-
bool operator> (const path& lhs, const path& rhs) noexcept;
12777+
bool operator< (const path& lhs, const path& rhs) noexcept;
1276112778
\end{itemdecl}
1276212779

1276312780
\begin{itemdescr}
1276412781
\pnum
12765-
\returns \tcode{rhs < lhs}.
12782+
\returns \tcode{lhs.compare(rhs) < 0}.
1276612783
\end{itemdescr}
1276712784

12768-
\indexlibrarymember{operator>=}{path}%
12785+
\indexlibrarymember{operator<=}{path}%
1276912786
\begin{itemdecl}
12770-
bool operator>=(const path& lhs, const path& rhs) noexcept;
12787+
bool operator<=(const path& lhs, const path& rhs) noexcept;
1277112788
\end{itemdecl}
1277212789

1277312790
\begin{itemdescr}
1277412791
\pnum
12775-
\returns \tcode{!(lhs < rhs)}.
12792+
\returns \tcode{!(rhs < lhs)}.
1277612793
\end{itemdescr}
1277712794

12778-
\indexlibrarymember{operator==}{path}%
12795+
\indexlibrarymember{operator>}{path}%
1277912796
\begin{itemdecl}
12780-
bool operator==(const path& lhs, const path& rhs) noexcept;
12797+
bool operator> (const path& lhs, const path& rhs) noexcept;
1278112798
\end{itemdecl}
1278212799

1278312800
\begin{itemdescr}
1278412801
\pnum
12785-
\returns \tcode{!(lhs < rhs) \&\& !(rhs < lhs)}.
12786-
12787-
\indextext{path equality}
12788-
\pnum
12789-
\begin{note} Path equality and path equivalence have different semantics.
12790-
\begin{itemize}
12791-
\item Equality is determined by the \tcode{path} non-member \tcode{operator==},
12792-
which considers the two paths' lexical representations only.
12793-
\begin{example} \tcode{path("foo") == "bar"} is never \tcode{true}. \end{example}
12794-
\item Equivalence is determined by the \tcode{equivalent()} non-member function, which
12795-
determines if two paths resolve\iref{fs.class.path} to the same file system entity.
12796-
\begin{example}
12797-
\tcode{equivalent("foo", "bar")} will be \tcode{true} when both paths resolve to the same file.
12798-
\end{example}
12799-
\end{itemize}
12800-
Programmers wishing to determine if two paths are ``the same'' must decide if
12801-
``the same'' means ``the same representation'' or ``resolve to the same actual
12802-
file'', and choose the appropriate function accordingly. \end{note}
12802+
\returns \tcode{rhs < lhs}.
1280312803
\end{itemdescr}
1280412804

12805-
\indexlibrarymember{operator"!=}{path}%
12805+
\indexlibrarymember{operator>=}{path}%
1280612806
\begin{itemdecl}
12807-
bool operator!=(const path& lhs, const path& rhs) noexcept;
12807+
bool operator>=(const path& lhs, const path& rhs) noexcept;
1280812808
\end{itemdecl}
1280912809

1281012810
\begin{itemdescr}
1281112811
\pnum
12812-
\returns \tcode{!(lhs == rhs)}.
12812+
\returns \tcode{!(lhs < rhs)}.
1281312813
\end{itemdescr}
1281412814

1281512815
\indexlibrarymember{operator/}{path}%
@@ -13391,11 +13391,11 @@
1339113391
file_status symlink_status() const;
1339213392
file_status symlink_status(error_code& ec) const noexcept;
1339313393

13394-
bool operator< (const directory_entry& rhs) const noexcept;
1339513394
bool operator==(const directory_entry& rhs) const noexcept;
1339613395
bool operator!=(const directory_entry& rhs) const noexcept;
13397-
bool operator<=(const directory_entry& rhs) const noexcept;
13396+
bool operator< (const directory_entry& rhs) const noexcept;
1339813397
bool operator> (const directory_entry& rhs) const noexcept;
13398+
bool operator<=(const directory_entry& rhs) const noexcept;
1339913399
bool operator>=(const directory_entry& rhs) const noexcept;
1340013400

1340113401
private:
@@ -13788,24 +13788,24 @@
1378813788
\returns \tcode{pathobject < rhs.pathobject}.
1378913789
\end{itemdescr}
1379013790

13791-
\indexlibrarymember{operator<=}{directory_entry}%
13791+
\indexlibrarymember{operator>}{directory_entry}%
1379213792
\begin{itemdecl}
13793-
bool operator<=(const directory_entry& rhs) const noexcept;
13793+
bool operator> (const directory_entry& rhs) const noexcept;
1379413794
\end{itemdecl}
1379513795

1379613796
\begin{itemdescr}
1379713797
\pnum
13798-
\returns \tcode{pathobject <= rhs.pathobject}.
13798+
\returns \tcode{pathobject > rhs.pathobject}.
1379913799
\end{itemdescr}
1380013800

13801-
\indexlibrarymember{operator>}{directory_entry}%
13801+
\indexlibrarymember{operator<=}{directory_entry}%
1380213802
\begin{itemdecl}
13803-
bool operator> (const directory_entry& rhs) const noexcept;
13803+
bool operator<=(const directory_entry& rhs) const noexcept;
1380413804
\end{itemdecl}
1380513805

1380613806
\begin{itemdescr}
1380713807
\pnum
13808-
\returns \tcode{pathobject > rhs.pathobject}.
13808+
\returns \tcode{pathobject <= rhs.pathobject}.
1380913809
\end{itemdescr}
1381013810

1381113811
\indexlibrarymember{operator>=}{directory_entry}%
@@ -14939,7 +14939,7 @@
1493914939

1494014940
\pnum
1494114941
\begin{note} The current path as returned by many operating systems is a dangerous
14942-
global variable. It may be changed unexpectedly by a third-party or system
14942+
global variable. It may be changed unexpectedly by third-party or system
1494314943
library functions, or by another thread. \end{note}
1494414944
\end{itemdescr}
1494514945

0 commit comments

Comments
 (0)