On Sat, 9 May 2026, 09:40 Christopher Bazley via Gcc, <[email protected]>
wrote:

>
>
> This flaw in the design of C++ is also what necessitated the invention
> of nullptr, which would otherwise be unnecessary. Had the purpose of
> 'void *' not been misunderstood, nullptr could simply have been defined
> as a macro: ((void *)0).


No it couldn't.

This thread is getting more and more of topic, but defining nullptr as just
a void* would not allow the useful property of overloading functions like
unique_ptr::operator= on whether the argument is an actual pointer (which
would replace the owned pointer, but is disallowed by plain assignment) or
is the special nullptr value (which is allowed).

That is:

uptr = (void*)0; // error
uptr = nullptr; // ok

I think you have an overly simplistic idea of why nullptr was added to C++,
leading to an incorrect conclusion about it only being necessary because of
C++ pointer conversion rules.

It exists for reasons related to template type deduction and overloading,
not because void* isn't convertible to other pointer types.

Reply via email to