I'm reading the documentation on std::expected::operator==
, and apparently it's not SFINAE-friendly. Instead of "doesn't participate in overload resolution if [types are not eq-comparable]", it says "the program is ill-formed [in that case]".
And indeed:
#include <concepts>
#include <expected>
struct A {};
static_assert(!std::equality_comparable<std::expected<A, A>>);
This assertion fails on MSVC and Clang with libc++, and causes a hard error on Clang with MSVC STL.
But why is it not SFINAE-friendly?
std::expected<T,U>
requires both T
and U
to be complete anyway, so seemingly nothing is stopping all operations on it to be SFINAE-friendly.
tl::expected
's==
is SFINAE-friendly, so it looks possible. – Ewardstruct A
(which is empty here)? – GerardogeratologyA
lacks==
, thenstd::expected
's==
must be disabled, sostd::equality_comparable
must return false for it. But here it returns true... – Eward