|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-04-17 16:03:21
Eric Niebler wrote:
> The implementation is quite trivial (see below).
Seems pretty complicated to me. The "canonical" counted_base is (assuming
namespace boost):
class counted_base
{
private:
mutable detail::atomic_count count_;
protected:
counted_base(): count_( 0 ) {}
virtual ~counted_base() {}
counted_base( counted_base const & ): count_( 0 ) {}
counted_base& operator=( counted_base const & ) { return *this; }
public:
inline friend void intrusive_ptr_add_ref( counted_base const * p )
{
++p->count_;
}
inline friend void intrusive_ptr_release( counted_base const * p )
{
if( --p->count_ == 0 ) delete p;
}
long use_count() const { return count_; }
};
Seeing so many variations of it is a pretty good indication that we need it
in Boost. :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk