Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1109: intrusive_ptr needs a helper base class
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-05-31 12:55:13
#1109: intrusive_ptr needs a helper base class
-------------------------------+--------------------------------------------
Reporter: pdimov | Owner: pdimov
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: smart_ptr
Version: | Severity: Problem
Resolution: | Keywords:
-------------------------------+--------------------------------------------
Comment (by NN):
Virtual destructor is not necessary here:
{{{
#!cpp
template<typename T>
class counted_base
{
private:
mutable detail::atomic_count count_;
protected:
counted_base(): count_( 0 ) {}
~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( T const * p )
{
++p->counted_base<T>::count_;
}
inline friend void intrusive_ptr_release( T const * p )
{
if( --p->counted_base<T>::count_ == 0 )
delete p;
}
long use_count() const { return count_; }
};
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/1109#comment:5> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC