c++ - Can a preexisting return of a typecast NULL be safely compared to a newer nullptr? -


i required use library written before c++11, , 1 of functions can return typecast null. i'm trying write program following c++11 standards, when protecting against null reference, use like:

if(retptr==nullptr){...} 

is safe comparison? arguments sake between (int*)null , (int*)nullptr? or should use an:

if(retptr){...}? 

can preexisting return of typecast null safely compared newer nullptr?

yes. cppreference.com:

there exist implicit conversions nullptr null pointer value of pointer type , pointer member type. similar conversions exist value of type std::nullptr_t macro null, null pointer constant.

as praetorian kindly pointed out, corresponding section of standard 4.10 [conv.ptr].

see what nullptr?


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -