|
849 | 849 | Subclause \ref{concepts.compare} describes concepts that establish relationships and orderings
|
850 | 850 | on values of possibly differing object types.
|
851 | 851 |
|
| 852 | +\pnum |
| 853 | +Given an expression \tcode{E} and a type \tcode{C}, |
| 854 | +let \tcode{\exposid{CONVERT_TO_LVALUE}<C>(E)} be: |
| 855 | +\begin{itemize} |
| 856 | +\item |
| 857 | +\tcode{static_cast<const C\&>(as_const(E))} if that is a valid expression, and |
| 858 | +\item |
| 859 | +\tcode{static_cast<const C\&>(std::move(E))} otherwise. |
| 860 | +\end{itemize} |
| 861 | + |
852 | 862 | \rSec2[concept.booleantestable]{Boolean testability}
|
853 | 863 |
|
854 | 864 | \pnum
|
|
985 | 995 | model \exposconcept{boolean-testable}.
|
986 | 996 | \end{example}
|
987 | 997 |
|
| 998 | +\rSec2[concept.comparisoncommontype]{Comparison common types} |
| 999 | + |
| 1000 | +\begin{itemdecl} |
| 1001 | +template<class T, class U, class C = common_reference_t<const T&, const U&>> |
| 1002 | + concept @\defexposconcept{comparison-common-type-with-impl}@ = // \expos |
| 1003 | + @\libconcept{same_as}@<common_reference_t<const T&, const U&>, |
| 1004 | + common_reference_t<const U&, const T&>> && |
| 1005 | + requires { |
| 1006 | + requires @\libconcept{convertible_to}@<const T&, const C&> || @\libconcept{convertible_to}@<T, const C&>; |
| 1007 | + requires @\libconcept{convertible_to}@<const U&, const C&> || @\libconcept{convertible_to}@<U, const C&>; |
| 1008 | + }; |
| 1009 | + |
| 1010 | +template<class T, class U> |
| 1011 | + concept @\defexposconcept{comparison-common-type-with}@ = // \expos |
| 1012 | + @\exposconcept{comparison-common-type-with-impl}@<remove_cvref_t<T>, remove_cvref_t<U>>; |
| 1013 | +\end{itemdecl} |
| 1014 | + |
| 1015 | +\pnum |
| 1016 | +Let \tcode{C} be \tcode{common_reference_t<const T\&, const U\&>}. |
| 1017 | +Let \tcode{t1} and \tcode{t2} be equality-preserving expressions |
| 1018 | +that are lvalues of type \tcode{remove_cvref_t<T>}, and |
| 1019 | +let \tcode{u1} and \tcode{u2} be equality-preserving expressions |
| 1020 | +that are lvalues of type \tcode{remove_cvref_t<U>}. |
| 1021 | +\tcode{T} and \tcode{U} model |
| 1022 | +\tcode{\exposconcept{comparison-common-type-with}<T, U>} only if: |
| 1023 | +\begin{itemize} |
| 1024 | +\item |
| 1025 | +\tcode{\exposid{CONVERT_TO_LVALUE}<C>(t1)} equals |
| 1026 | +\tcode{\exposid{CONVERT_TO_LVALUE}<C>(t2)} |
| 1027 | +if and only if \tcode{t1} equals \tcode{t2}, and |
| 1028 | +\item |
| 1029 | +\tcode{\exposid{CONVERT_TO_LVALUE}<C>(u1)} equals |
| 1030 | +\tcode{\exposid{CONVERT_TO_LVALUE}<C>(u2)} |
| 1031 | +if and only if \tcode{u1} equals \tcode{u2} |
| 1032 | +\end{itemize} |
| 1033 | + |
988 | 1034 | \rSec2[concept.equalitycomparable]{Concept \cname{equality_comparable}}
|
989 | 1035 |
|
990 | 1036 | \begin{itemdecl}
|
|
1039 | 1085 | template<class T, class U>
|
1040 | 1086 | concept @\deflibconcept{equality_comparable_with}@ =
|
1041 | 1087 | @\libconcept{equality_comparable}@<T> && @\libconcept{equality_comparable}@<U> &&
|
1042 |
| - @\libconcept{common_reference_with}@<const remove_reference_t<T>&, const remove_reference_t<U>&> && |
| 1088 | + @\exposconcept{comparison-common-type-with}@<T, U> && |
1043 | 1089 | @\libconcept{equality_comparable}@<
|
1044 | 1090 | common_reference_t<
|
1045 | 1091 | const remove_reference_t<T>&,
|
|
1050 | 1096 | \begin{itemdescr}
|
1051 | 1097 | \pnum
|
1052 | 1098 | Given types \tcode{T} and \tcode{U},
|
1053 |
| -let \tcode{t} be an lvalue of type \tcode{const remove_reference_t<T>}, |
1054 |
| -\tcode{u} be an lvalue of type \tcode{const remove_reference_t<U>}, |
1055 |
| -and \tcode{C} be: |
| 1099 | +let \tcode{t} and \tcode{t2} be lvalues |
| 1100 | +denoting distinct equal objects of types \tcode{const remove_reference_t<T>} and |
| 1101 | +\tcode{remove_cvref_t<T>}, respectively, |
| 1102 | +let \tcode{u} and \tcode{u2} be lvalues |
| 1103 | +denoting distinct equal objects of types \tcode{const remove_reference_t<U>} and |
| 1104 | +\tcode{remove_cvref_t<U>}, respectively, and |
| 1105 | +let \tcode{C} be: |
1056 | 1106 | \begin{codeblock}
|
1057 | 1107 | common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>
|
1058 | 1108 | \end{codeblock}
|
1059 | 1109 | \tcode{T} and \tcode{U} model
|
1060 | 1110 | \tcode{\libconcept{equality_comparable_with}<T, U>} only if
|
1061 |
| -\tcode{bool(t == u) == bool(C(t) == C(u))}. |
| 1111 | +\begin{codeblock} |
| 1112 | +bool(t == u) == bool(@\exposid{CONVERT_TO_LVALUE}@<C>(t2) == @\exposid{CONVERT_TO_LVALUE}@<C>(u2)) |
| 1113 | +\end{codeblock} |
1062 | 1114 | \end{itemdescr}
|
1063 | 1115 |
|
1064 | 1116 | \rSec2[concept.totallyordered]{Concept \cname{totally_ordered}}
|
|
1101 | 1153 | \begin{itemdescr}
|
1102 | 1154 | \pnum
|
1103 | 1155 | Given types \tcode{T} and \tcode{U},
|
1104 |
| -let \tcode{t} be an lvalue of type \tcode{const remove_reference_t<T>}, |
1105 |
| -\tcode{u} be an lvalue of type \tcode{const remove_reference_t<U>}, |
1106 |
| -and \tcode{C} be: |
| 1156 | +let \tcode{t} and \tcode{t2} be lvalues |
| 1157 | +denoting distinct equal objects of types \tcode{const remove_reference_t<T>} and |
| 1158 | +\tcode{remove_cvref_t<T>}, respectively, |
| 1159 | +let \tcode{u} and \tcode{u2} be lvalues |
| 1160 | +denoting distinct equal objects of types \tcode{const remove_reference_t<U>} and |
| 1161 | +\tcode{remove_cvref_t<U>}, respectively, and |
| 1162 | +let \tcode{C} be: |
1107 | 1163 | \begin{codeblock}
|
1108 | 1164 | common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>
|
1109 | 1165 | \end{codeblock}
|
1110 | 1166 | \tcode{T} and \tcode{U} model
|
1111 | 1167 | \tcode{\libconcept{totally_ordered_with}<T, U>} only if
|
1112 |
| - |
1113 | 1168 | \begin{itemize}
|
1114 |
| -\item \tcode{bool(t < u) == bool(C(t) < C(u)).} |
1115 |
| -\item \tcode{bool(t > u) == bool(C(t) > C(u)).} |
1116 |
| -\item \tcode{bool(t <= u) == bool(C(t) <= C(u)).} |
1117 |
| -\item \tcode{bool(t >= u) == bool(C(t) >= C(u)).} |
1118 |
| -\item \tcode{bool(u < t) == bool(C(u) < C(t)).} |
1119 |
| -\item \tcode{bool(u > t) == bool(C(u) > C(t)).} |
1120 |
| -\item \tcode{bool(u <= t) == bool(C(u) <= C(t)).} |
1121 |
| -\item \tcode{bool(u >= t) == bool(C(u) >= C(t)).} |
| 1169 | +\item \tcode{bool(t < u) == bool(\exposid{CONVERT_TO_LVALUE}<C>(t2) < \exposid{CONVERT_TO_LVALUE}<C>(u2))}. |
| 1170 | +\item \tcode{bool(t > u) == bool(\exposid{CONVERT_TO_LVALUE}<C>(t2) > \exposid{CONVERT_TO_LVALUE}<C>(u2))}. |
| 1171 | +\item \tcode{bool(t <= u) == bool(\exposid{CONVERT_TO_LVALUE}<C>(t2) <= \exposid{CONVERT_TO_LVALUE}<C>(u2))}. |
| 1172 | +\item \tcode{bool(t >= u) == bool(\exposid{CONVERT_TO_LVALUE}<C>(t2) >= \exposid{CONVERT_TO_LVALUE}<C>(u2))}. |
| 1173 | +\item \tcode{bool(u < t) == bool(\exposid{CONVERT_TO_LVALUE}<C>(u2) < \exposid{CONVERT_TO_LVALUE}<C>(t2))}. |
| 1174 | +\item \tcode{bool(u > t) == bool(\exposid{CONVERT_TO_LVALUE}<C>(u2) > \exposid{CONVERT_TO_LVALUE}<C>(t2))}. |
| 1175 | +\item \tcode{bool(u <= t) == bool(\exposid{CONVERT_TO_LVALUE}<C>(u2) <= \exposid{CONVERT_TO_LVALUE}<C>(t2))}. |
| 1176 | +\item \tcode{bool(u >= t) == bool(\exposid{CONVERT_TO_LVALUE}<C>(u2) >= \exposid{CONVERT_TO_LVALUE}<C>(t2))}. |
1122 | 1177 | \end{itemize}
|
1123 | 1178 | \end{itemdescr}
|
1124 | 1179 |
|
|
0 commit comments