Working with C++20's concepts I noticed that std::unique_ptr appears to fail to satisfy the std::equality_comparable_with concept. From std::unique_ptr's definition, it is supposed to implement the following when in C++20:
template
bool operator==(const unique_ptr& x, const unique_ptr& y);
template
bool operator==(const unique_ptr& x, std::nullptr_t) noexcept;
This requirement should implement symmetric comparison with nullptr -- which from my understanding is sufficient for satisfying equality_comparable_with.
Curiously, this issue appears to be consistent on all the major compilers. The following code is rejected from Clang, GCC, and MSVC:
// fails on all three compilers
static_assert(std::equality_comparable_with,std::nullptr_t>);
However the same assertion with std::shared_ptr is accepted:
// succeeds on all three compilers
static_assert(std::equality_comparable_with,std::nullptr_t>);
Unless I'm misunderstanding something, this appears to be a bug. My question is whether this is a coincidental bug in the three compiler implementations, or is this a defect in the C++20 standard?
Note: I'm tagging this language-lawyer in case this happens to be a defect.