In Effective Modern C++, "Iterm 8: Prefer nullptr to 0 and NULL.", Page 59, it says:
nullptr
's actual type isstd::nullptr_t
, and, in a wonderfully circular definition,std::nullptr_t
is defined to be the type ofnullptr
.
A wonderfully circular definition?
How that comes?
In brief, nullptr
is a value that can be assigned to a pointer to any type, and it is false in boolean context (unlike most pointers that are results of new
/malloc
, or referencing a valid object), and despite itself being a valid pointer, dereferencing it results in UB, as does in/decrementing it, and it is a sole value of a singleton type nullptr_t
.
Something like this.