Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-04-26 09:56:51


On Sat, 2008-04-26 at 15:45 +0300, Peter Dimov wrote:
> Daniel Frey:
> >I refactored enable_shared_from_this in order to remove the _owner flag.
> >
> > To test it, you need a small and straight-forward addition to
> > detail::weak_count: It needs .empty(), similar to detail::shared_count.
>
> Are you sure that you need to test for emptiness instead of expiration?

I'm not sure, because I don't know what is expected. I initially
used .use_count() != 0, but it triggered a problem in
esft_constructor_test.cpp, line 131. I already asked Frank for more
information/documentation about what (the new) esft should support, but
he said that there is no documentation, instead he pointed me to the
regression tests, so I figured I need to make them pass. With .empty(),
they do.

When looking at the test case that fails with .use_count() != 0, I don't
really see why the call to shared_from_this() in line 130 should throw.
Shouldn't the call alone be legal? The only illegal thing I could spot
in this test case is, that after calling x.shared_from_this() no other
shared_ptr takes ownership of x.

Regards, Daniel

PS: I already committed the fix for the new shared_ptr's ctors. What
about adding the corresponding reset()? The refactored esft could use it
to simplify one line. And what's your opinion on documenting the new
interface? (You've seen the documentation thread?)


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