📅 2014-Sep-17 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cpp, nullptr ⬩ 📚 Archive
In C++11 and later versions, we can now use a proper null pointer value. It is named as nullptr
and is a C++ keyword. Unlike 0
or NULL
which were an integer and a pointer to void
respectively, nullptr
is cleaner and brings in stronger type checking. nullptr
can be assigned to any pointer variable.
I could not find the definition of nullptr
, I guess it is defined inside the compiler itself. The closest I could find is nullptr_t
, which is the type of nullptr
. For GCC 4.9, I found that this is defined in /usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h
:
typedef decltype(nullptr) nullptr_t;
Tried with: GCC 4.9.1 and Ubuntu 14.04