nullptr
is a C++11 keyword (no different to if
, public
, true
, void
, etc.), so namespaces don't apply.
Why isn't 'nullptr' in the 'std' namespace?
Frage
It seems that nullptr
is declared in the default global namespace. Wouldn't it make sense for it to be in the std
namespace?
Lösung
Andere Tipps
nullptr
is a pointer literal the same way as for example true
is a boolean literal. This literal has type std::nullptr_t
that is as you see this type is defined in name space std::
The pointer literal is described in section 2.14.7 Pointer literals of the C++ Standard.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow