Skip to content

Commit 3a129f2

Browse files
burblebeetkoeppe
authored andcommitted
LWG3746 optional's spaceship with U with a type derived from optional causes infinite constraint meta-recursion
1 parent 2014b74 commit 3a129f2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

source/utilities.tex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,9 +3131,9 @@
31313131
class optional;
31323132

31333133
template<class T>
3134-
constexpr bool @\exposid{is-optional}@ = false; // \expos
3135-
template<class T>
3136-
constexpr bool @\exposid{is-optional}@<optional<T>> = true; // \expos
3134+
concept @\defexposconcept{is-derived-from-optional}@ = requires(const T& t) { // \expos
3135+
[]<class U>(const optional<U>&){ }(t);
3136+
};
31373137

31383138
// \ref{optional.nullopt}, no-value state indicator
31393139
struct nullopt_t{@\seebelow@};
@@ -3177,7 +3177,8 @@
31773177
template<class T, class U> constexpr bool operator<=(const T&, const optional<U>&);
31783178
template<class T, class U> constexpr bool operator>=(const optional<T>&, const U&);
31793179
template<class T, class U> constexpr bool operator>=(const T&, const optional<U>&);
3180-
template<class T, class U> requires (!@\exposid{is-optional}@<U>) && @\libconcept{three_way_comparable_with}@<T, U>
3180+
template<class T, class U>
3181+
requires (!@\exposconcept{is-derived-from-optional}@<U>) && @\libconcept{three_way_comparable_with}@<T, U>
31813182
constexpr compare_three_way_result_t<T, U>
31823183
operator<=>(const optional<T>&, const U&);
31833184

@@ -4748,7 +4749,8 @@
47484749

47494750
\indexlibrarymember{operator<=>}{optional}%
47504751
\begin{itemdecl}
4751-
template<class T, class U> requires (!@\exposid{is-optional}@<U>) && @\libconcept{three_way_comparable_with}@<T, U>
4752+
template<class T, class U>
4753+
requires (!@\exposconcept{is-derived-from-optional}@<U>) && @\libconcept{three_way_comparable_with}@<T, U>
47524754
constexpr compare_three_way_result_t<T, U>
47534755
operator<=>(const optional<T>& x, const U& v);
47544756
\end{itemdecl}

0 commit comments

Comments
 (0)