|
Boost : |
Subject: Re: [boost] Why no non-null smart pointers?
From: Jeff Hill (johill_at_[hidden])
Date: 2014-04-28 11:20:35
Ross MacGregor wrote
> "Johan RÃ¥de" <
> rade_at_.lth
> > wrote in message
> news:ft10ag$6nn$
> 1_at_.gmane
> ...
>
> I know it is an insane idea to suggest changing the entire
> boost::smart_ptr library to a boost::smart_ref library, but I
> think it may actually be the right thing to do. Does anyone
> agree?
I also find the nill state of shared_ptr to be a liability when designing
interfaces. The primary purpose of shared_ptr when used in an interface
context is to convey ownership, and almost always it feels wrong to also
provide simultaneously an option to convey ownership of nothing. The poor
user is left with the responsibility of testing every shared_ptr he has
received for null state before using it, but its easy to forget and the
compiler provides no assistance. Ultimately, the library interface based on
shared_ptr is more error prone, less likely to be easy to use, and therefore
arguably suboptimal.
Of course no one suggests that shared_ptr should (or could) be changed in
ways that impacts backwards compatibility, but I have to agree with the
author of the post that this issue can be identified as a legitimate cause
for concern.
Jeff
-- View this message in context: http://boost.2283326.n4.nabble.com/Why-no-non-null-smart-pointers-tp2642959p4661797.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