Can nullptr be emulated in gcc?

The Official proposal has a workaround – const // this is a const object… class { public: template<class T> // convertible to any type operator T*() const // of null non-member { return 0; } // pointer… template<class C, class T> // or any type of null operator T C::*() const // member pointer… { … Read more

NULL vs nullptr (Why was it replaced?) [duplicate]

nullptr has type std::nullptr_t. It’s implicitly convertible to any pointer type. Thus, it’ll match std::nullptr_t or pointer types in overload resolution, but not other types such as int. 0 (aka. C’s NULL bridged over into C++) could cause ambiguity in overloaded function resolution, among other things: f(int); f(foo *); (Thanks to Caleth pointing this out … Read more

What exactly is nullptr?

How is it a keyword and an instance of a type? This isn’t surprising. Both true and false are keywords and as literals they have a type ( bool ). nullptr is a pointer literal of type std::nullptr_t, and it’s a prvalue (you cannot take the address of it using &). 4.10 about pointer conversion … Read more