Alex Rivera | Logout

boost Shared_pointer NULL

Asked 2011-04-10T08:10:51.577
30

I'm using reset() as a default value for my shared_pointer (equivalent to a NULL).

But how do I check if the shared_pointer is NULL?

Will this return the right value ?

boost::shared_ptr<Blah> blah;
blah.reset()
if (blah == NULL) 
{
    //Does this check if the object was reset() ?
}
Edit
Report

1 Answer

11

if blah == NULL will work fine. Some people would prefer it over testing as a bool (if !blah) because it's more explicit. Others prefer the latter because it's shorter.

answered 2011-04-10T14:45:28.180

Your Answer