A nullptr or the nullptr

  • A+
Category:Languages

If I am talking about nullptr, is the correct terminology the nullptr (there is only one, and all mentions are references to the same thing), or a nullptr (there are several identical things).

That is, should function documentation say

If ptr is the nullptr, the function uses an internal buffer...

or

If ptr is a nullptr, the function uses an internal buffer...


nullptr is a keyword which designates a prvalue of type std::nullptr_t. Super-formally, a pointer can therefore not be [a|the] nullptr. It can, however, "be null" (or "have a null value").

In your documentation example, I would simply say

If ptr is null, the function ...

Note that std::nullptr_t (and thus nullptr) is not even a pointer type! It's a special type which can be converted to any pointer to object, pointer to function, or pointer to member. Which I consider as extra justification for not speaking about pointers being nullptr; pointers are just null.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: