Boost logo

Boost :

From: Richard Damon (rdamon_at_[hidden])
Date: 2002-04-18 15:07:23


> -----Original Message-----
> From: boost-admin_at_[hidden] [mailto:boost-admin_at_[hidden]]On
> Behalf Of Fernando Cacciola
> Sent: Thursday, April 18, 2002 1:35 PM
> To: boost_at_[hidden]
> Subject: [boost] Re: Re: Intrusive smart pointer
>
>
> class shared_object
> {
> protected :
>
> shared_object () : m_reference_count ( 0 ) {}
> shared_object ( const shared_object & ) : m_reference_count ( 0 ) {}
> virtual ~ shared_object () {}
>
> shared_object& operator = ( const shared_object & )
> { m_reference_count = 0 ; return * this ; }

Why are you zeroing the reference count? I would think operator = () would
be a no-op, since any pointer to you are still pointing to you.

>
> public :
>
> void increment_reference_count() const { ++ m_reference_count ; }
> void decrement_reference_count() const
> {
> if ( -- m_reference_count == 0 )
> delete this ;
> }
>
> bool is_object_shared() const { return m_reference_count > 0 ; }
>
> private :
>
> mutable std::size_t m_reference_count ;
> } ;


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