https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111504
--- Comment #2 from Xiang Gao ---
(In reply to Andrew Pinski from comment #1)
> Fails for the same reason with clang (both with libstdc++ and libc++)
>
> Are you sure this is valid C++ 20 code?
I am not 100% sure, but my understanding is, for the SFINAE in
inline constexpr bool operator<(const DT& x, const DT& y)
The first condition
hasLessThan::value
is just hasLessThan::value, which should be true, and (true
|| anything) is always true.
So the condition in SFINAE should be easily evaluated as true. So the operator<
for DynamicType should be defined.
And if operator< is defined, then the operator<=> of std::vector
should also be defined. This can be validated by changing the definition of
operator< by only keeping the first condition:
template <
typename DT,
typename = std::enable_if_t<
(hasLessThan::value)>>
inline constexpr bool operator<(const DT& x, const DT& y) {
// implementation omitted
return true;
}
and then both g++ and clang++ will pass.
I do observe the same error on clang, but this https://cpp.sh/ seems to compile
without problem on C++20.