We have a large legacy codebase with commonly referenced pointer types that are, for various reasons, better suited to being shared_ptrs.
shared_ptrs are nice drop-in replacements for regular pointers except for NULL checks. Throughout the code we have regular NULL checks on these pointers and after conversion to shared_ptrs these null checks will always pass.
Does anybody have a nice way of automatically detecting these cases: if (foo == NULL) // when foo is a boost::shared_ptr ?
We are not yet on C++11 but will be soon.
Example:
// declared elsewhere as : boost::shared_ptr<T> foo;
if (NULL != foo) //always true when shared_ptr. Correct check when raw pointer
{
foo->DoSomething();
}