|
Boost : |
Subject: Re: [boost] Why no non-null smart pointers?
From: Jeff Hill (johill_at_[hidden])
Date: 2014-04-28 13:42:09
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 ();
}
}
Jeff
-- View this message in context: http://boost.2283326.n4.nabble.com/Why-no-non-null-smart-pointers-tp2642959p4661800.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk