Will C++11 implementations define NULLas nullptr?
Would this be prescribed by the new C++ standard?
nullptr is meant as a replacement to NULL . nullptr provides a typesafe pointer value representing an empty (null) pointer. The general rule of thumb that I recommend is that you should start using nullptr whenever you would have used NULL in the past.
The C++11 standard introduced a new keyword, nullptr as a null pointer constant. The nullptr constant can be distinguished from integer 0 for overloaded functions.
The C standard requires that NULL be defined in locale. h , stddef. h , stdio. h , stdlib.
In computer programming, null is both a value and a pointer. Null is a built-in constant that has a value of zero. It is the same as the character 0 used to terminate strings in C. Null can also be the value of a pointer, which is the same as zero unless the CPU supports a special bit pattern for a null pointer.
From the horse's mouth
C.3.2.4 Macro NULL [diff.null]
1/ The macro NULL, defined in any of
<clocale>,<cstddef>,<cstdio>,<cstdlib>,<cstring>,<ctime>, or<cwchar>, is an implementation-defined C++ null pointer constant in this International Standard (18.2).
It is up to each implementation to provide its own definition, gcc if I recall correctly defines it to __nullptr for which it has special checks (verifies that it is not used in arithmetic contexts for example).
So it is possible to define it as nullptr, you will have to check your compiler/Standard Library documentation to see what has been done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With