|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2003-01-29 11:55:26
"David Abrahams" <dave_at_[hidden]> wrote in message
news:uptqg32x2.fsf_at_boost-consulting.com...
> [...]
> I was half-joking. Imagine you used an auto_ptr in the
> implementation of SmartPtr<>.
> [...]
Well, help me reason this out anyway, because this is a gray area for me.
We would have to put the auto_ptr<> in a StoragePolicy (otherwise,
you defeat the point of PBD), and then we would have to make sure that
the StoragePolicy was the first member to get initialized, right? Then we
would have to guarantee that StoragePolicy is no-throw, or we defeat the
whole purpose of this little game, right? That means that StoragePolicy()
will always succeed, and thus, the StoragePolicy sub-object will be fully
constructed before any of the other policy constructors are called? Then,
if one of the other c'tors does throw, the StoragePolicy d'tor will get
called, even though the SmartPtr is not fully constructed, and that will
clean up the resource? Or am I missing something?
It seems that the function try block is slightly more powerful, because it
does not require StoragePolicy() to be no-throw.
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk