Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-03-26 04:32:33


On Wed, 2008-03-26 at 09:07 +0100, Kevin Scarr wrote:
> Daniel Frey wrote:
> > does shared_from_this() also guarantee that it never throws?
>
> I think sharead_from_this() can not make this guarantee since it uses
> BOOST_ASSERT() which can be defined to call a user-supplied assertion
> handler. That handler could, of course, throw.

Yepp, but I think it's not relevant. Does it guarantee to never throw
when used correctly? A lot of exception guarantees expect dtor's to
never throw, although in theory they could. asserts (which also includes
BOOST_ASSERT) are meant to be never triggered when used correctly,
right? So a guarantee like "never throws" always assumes correct usage.

Also, my question is not about the current *implementation* (or any
specific implementation at all), but about the *interface* shared_ptrs
intends to provide. What happens if I switch to GCC's implementation of
std::shared_ptr in the future? Or some other compiler/platform? Can I
rely on certain functions to never throw? I just think that this needs
to be documented clearly.

Regards, Daniel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk