Skip to content

Commit 51684d2

Browse files
committed
[over.match.oper] Refactor the <=> rewrite candidate rules for clarity.
1 parent e0a88df commit 51684d2

File tree

1 file changed

+47
-42
lines changed

1 file changed

+47
-42
lines changed

source/overloading.tex

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,12 @@
975975
\tcode{T1}
976976
and a right operand of a type whose cv-unqualified version is
977977
\tcode{T2},
978-
three sets of candidate functions, designated
978+
four sets of candidate functions, designated
979979
\defnx{member candidates}{member candidate},
980-
\defnx{non-member candidates}{non-member candidate}
981-
and \defnx{built-in candidates}{built-in candidate},
980+
\defnx{non-member candidates}{non-member candidate},
981+
\defnx{built-in candidates}{built-in candidate},
982+
and
983+
\defnx{rewritten candidates}{rewritten candidate},
982984
are constructed as follows:
983985
\begin{itemize}
984986
\item
@@ -1033,6 +1035,37 @@
10331035
do not have the same parameter-type-list as any non-member candidate
10341036
that is not a function template specialization.
10351037
\end{itemize}
1038+
1039+
\item
1040+
For the
1041+
relational\iref{expr.rel} and
1042+
equality\iref{expr.eq} operators,
1043+
the rewritten candidates include
1044+
all member, non-member, and built-in candidates
1045+
for the operator \tcode{<=>}
1046+
for which the rewritten expression
1047+
\tcode{(x <=> y) @ 0} is well-formed using that \tcode{operator<=>}.
1048+
For the
1049+
relational\iref{expr.rel},
1050+
equality\iref{expr.eq},
1051+
and
1052+
three-way comparison\iref{expr.spaceship}
1053+
operators,
1054+
the rewritten candidates also include
1055+
a synthesized candidate,
1056+
with the order of the two parameters reversed,
1057+
for each member, non-member, and built-in candidate
1058+
for the operator \tcode{<=>}
1059+
for which the rewritten expression
1060+
\tcode{0 @ (y <=> x)} is well-formed using that \tcode{operator<=>}.
1061+
\begin{note}
1062+
A candidate synthesized from a member candidate has its implicit
1063+
object parameter as the second parameter, thus implicit conversions
1064+
are considered for the first, but not for the second, parameter.
1065+
\end{note}
1066+
In each case, rewritten candidates are not considered
1067+
in the context of the rewritten expression.
1068+
For all other operators, the rewritten candidate set is empty.
10361069
\end{itemize}
10371070

10381071
\pnum
@@ -1054,41 +1087,12 @@
10541087
The set of candidate functions for overload resolution
10551088
for some operator \tcode{@}
10561089
is the
1057-
union of the member candidates, the non-member candidates, and
1058-
the built-in candidates for that operator \tcode{@}.
1059-
If that operator is a
1060-
relational\iref{expr.rel},
1061-
equality\iref{expr.eq},
1062-
or three-way comparison\iref{expr.spaceship}
1063-
operator
1064-
with operands \tcode{x} and \tcode{y},
1065-
then for each member, non-member, or built-in candidate
1066-
for the operator \tcode{<=>}:
1067-
\begin{itemize}
1068-
\item
1069-
that operator is added to the set of candidate functions for overload resolution
1070-
if \tcode{@} is not \tcode{<=>}
1071-
and \tcode{(x <=> y) @ 0} is well-formed using that \tcode{operator<=>}; and
1072-
\item
1073-
a synthesized candidate is added to the candidate set
1074-
where the order of the two parameters is reversed
1075-
if \tcode{0 @ (y <=> x)} is well-formed using that \tcode{operator<=>};
1076-
\end{itemize}
1077-
where in each case,
1078-
\begin{itemize}
1079-
\item if \tcode{@} is not \tcode{<=>},
1080-
\tcode{operator<=>} candidates
1081-
are not considered for the recursive lookup of operator \tcode{@}
1082-
and
1083-
\item
1084-
synthesized \tcode{operator<=>} candidates
1085-
are not considered for the recursive lookups.
1086-
\end{itemize}
1087-
\begin{note}
1088-
A candidate synthesized from a member candidate has its implicit
1089-
object parameter as the second parameter, thus implicit conversions
1090-
are considered for the first, but not for the second, parameter.
1091-
\end{note}
1090+
union of
1091+
the member candidates,
1092+
the non-member candidates,
1093+
the built-in candidates,
1094+
and the rewritten candidates
1095+
for that operator \tcode{@}.
10921096

10931097
\pnum
10941098
The argument list contains all of the
@@ -1112,14 +1116,15 @@
11121116
\end{example}
11131117

11141118
\pnum
1115-
If an \tcode{operator<=>} candidate
1119+
If a rewritten candidate
11161120
is selected by overload resolution for an operator \tcode{@},
11171121
\tcode{x @ y}
1118-
is interpreted as \tcode{0 @ (y <=> x)}
1122+
is interpreted as the rewritten expression:
1123+
\tcode{0 @ (y <=> x)}
11191124
if the selected candidate is a synthesized candidate
11201125
with reversed order of parameters,
1121-
or \tcode{(x <=> y) @ 0} if \tcode{@} is not \tcode{<=>},
1122-
using the selected \tcode{operator<=>} candidate.
1126+
or \tcode{(x <=> y) @ 0} otherwise,
1127+
using the selected rewritten \tcode{operator<=>} candidate.
11231128

11241129
\pnum
11251130
If a built-in candidate is selected by overload resolution, the

0 commit comments

Comments
 (0)