Is it safe to compare pointers where one is NULL and other is nullptr? Will that comparison always give true?
Yes.
Both NULL
and nullptr
are "null pointer constants" and
A null pointer constant can be converted to a pointer type; the result is the null pointer value of that type and is distinguishable from every other value of object pointer or function pointer type.
Lastly,
Two null pointer values of the same type shall compare equal.
(Both quotes 4.10/1 in N4140)
Assuming that NULL
is 0
(either through a #define
or an integral type definition) then, yes.
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