Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-04-18 16:22:53


"Richard Damon" <rdamon_at_[hidden]> wrote in message
news:KBEEJNHPFAMCGLNKDFEFOEJNDGAA.rdamon_at_beltronicsinc.com...
>
>
> > -----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.
>
Excellent spot!! This is indeed a bug, and as you said, it should be a
no-op.

(I've never pay enough attention to this before, perhaps, because we never
copy (non-initializing) a shared_object)

NOTE: It should not copy the source ref-count, of course, but it shouldn't
zero-it either.

Thanks!

--
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com

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