C++ Logo

std-proposals

Advanced search

Re: nullptr_t and nullopt_t should both have operator<=> and operator== to enable the *_with concepts

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Sat, 10 Jul 2021 01:41:07 +0200
Just wondering:

> static_cast<void>(p < nullptr); // invalid

How come that this is meaningless and disallowed...


> static_cast<void>(std::unique_ptr<char*>() < nullptr);// valid
>
> static_cast<void>(std::shared_ptr<char*>() < nullptr);// valid

... and these are well-defined and allowed?

I mean, not "how is it possible that they work" ("because they use
std::less"), but why are they even meaningful questions to ask in the
first place -- if smart pointer comparison is supposed to model raw
pointer comparison, and raw pointer comparison does not model such a thing?


Thanks,
-- 
Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2021-07-09 18:41:15