|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-03-20 11:25:57
Frank Mori Hess wrote:
> On Wednesday 19 March 2008 17:41 pm, Peter Dimov wrote:
>> What is the purpose of owned()?
>
> It indicates whether the object has had ownership passed to a
> shared_ptr yet. I don't have a strong justification on why it needs
> to be public, maybe it would be useful for debugging/diagnostic
> purposes.
It's better to omit the owned() accessor unless/until we have a use case for
it.
> Attached is a test for the new functionality.
Looks good. In:
{
boost::weak_ptr<X> early_weak_px;
{
boost::shared_ptr<X> early_px;
X x( 0, &early_px );
boost::weak_ptr<X> early_weak_px = early_px;
early_px.reset();
BOOST_TEST( early_weak_px.expired() == false );
BOOST_TEST( X::instances == 1 );
}
BOOST_TEST( early_weak_px.expired() );
}
you probably didn't want to redeclare early_weak_px inside the {} block
though.
As a minor stylistic issue, I'd prefer !expired() instead of expired() ==
false.
You might want to add tests for ownership sharing, !( early_px < px ) &&
!( px < early_px ).
One final question, in:
BOOST_TEST( early_px.use_count() > 0 );
what does use_count() return? 2? Do we want to test against 2 directly, or
are we to leave the initial use count unspecified?
Do you have SVN write access?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk