On Mon, Apr 28, 2014 at 9:42 PM, Jeff Hill
Maybe there /is/ even a backwards compatible solution.
Perhaps an optional null object pattern could be employed in methods, and or constructors, of shared_ptr that might establish a raw nill state? Perhaps something like this obviously oversimplified example could be use.
template < typename T> void shared_ptr < T > :: reset ( T * p = 0 ) { if ( p ) { /* what happens in shared_ptr now */ } else { /* new behavior in shared_ptr, when it detects a nill raw pointer */ *this = NullObjectTypes < T > :: factory (); } }
Please, don't change shared_ptr (or any other *_ptr) behavior. They are intended to behave as pointers, and pointers do have a null state. This is a useful feature in many cases. I'd prefer the functionality you're looking for to be implemented as a separate component/library. It may be based on pointers internally though.