[Cppunit-cvs] cppunit2/include/cpptl intrusiveptr.h,1.2,1.3
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-11-13 11:00:49
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18861/include/cpptl Modified Files: intrusiveptr.h Log Message: - inlined IntrusivePtrBase in IntrusivePtr. Index: intrusiveptr.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/intrusiveptr.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** intrusiveptr.h 13 Nov 2005 10:12:01 -0000 1.2 --- intrusiveptr.h 13 Nov 2005 11:00:41 -0000 1.3 *************** *** 44,104 **** namespace CppTL { - /// \cond implementation_detail - namespace Impl { - - /// Smart-pointer base class - class IntrusivePtrBase - { - public: - operator bool() const - { - return p_ != 0; - } - - bool operator !() const - { - return p_ == 0; - } - protected: - IntrusivePtrBase() - : p_( 0 ) - { - } - - IntrusivePtrBase( void *p ) - : p_( p ) - { - } - - IntrusivePtrBase( const IntrusivePtrBase &other ) - : p_( other.p_ ) - { - } - - void swap( IntrusivePtrBase &other ) - { - CppTL::swap( p_, other.p_ ); - } - - void *get() const - { - return p_; - } - - void *deref() const - { - // assert( p_ != 0 ) - return p_; - } - - //private: // Friend template function is not well supported - // Private access required by function staticPointerCast<> - public: - void *p_; - }; - - } // namespace Impl - /// \endcond - inline void instrusivePtrAddRef( IntrusiveCount *p ) { --- 44,47 ---- *************** *** 111,128 **** } - /// \todo inline Impl::IntrusivePtrBase into this class: it makes debugging more complex template<class PointeeType> ! class IntrusivePtr : public Impl::IntrusivePtrBase { public: typedef IntrusivePtr<PointeeType> ThisType; - typedef Impl::IntrusivePtrBase SuperClass; IntrusivePtr() { } IntrusivePtr( PointeeType *p ) ! : SuperClass( p ) { if ( p ) --- 54,70 ---- } template<class PointeeType> ! class IntrusivePtr { public: typedef IntrusivePtr<PointeeType> ThisType; IntrusivePtr() + : p_( 0 ) { } IntrusivePtr( PointeeType *p ) ! : p_( p ) { if ( p ) *************** *** 131,138 **** IntrusivePtr( const ThisType &other ) ! : Impl::IntrusivePtrBase( other ) { if ( p_ ) ! instrusivePtrAddRef( get() ); } --- 73,80 ---- IntrusivePtr( const ThisType &other ) ! : p_( other.p_ ) { if ( p_ ) ! instrusivePtrAddRef( p_ ); } *************** *** 140,144 **** { if ( p_ ) ! intrusivePtrRelease( get() ); } --- 82,86 ---- { if ( p_ ) ! intrusivePtrRelease( p_ ); } *************** *** 157,169 **** PointeeType *get() const { ! return static_cast<PointeeType *>( IntrusivePtrBase::get() ); } ! void swap( IntrusivePtr &other ) { ! SuperClass::swap( other ); } ! ThisType &operator =( const IntrusivePtr &other ) { ThisType tmp( other ); --- 99,111 ---- PointeeType *get() const { ! return p_; } ! void swap( ThisType &other ) { ! CppTL::swap( p_, other.p_ ); } ! ThisType &operator =( const ThisType &other ) { ThisType tmp( other ); *************** *** 175,185 **** { // assert( p_ != 0 ) ! return *( static_cast<PointeeType *>( p_ ) ); } PointeeType *operator ->() const { ! return static_cast<PointeeType *>( SuperClass::deref() ); } }; --- 117,140 ---- { // assert( p_ != 0 ) ! return *p_; } PointeeType *operator ->() const { ! return p_; } + + operator bool() const + { + return p_ != 0; + } + + bool operator !() const + { + return p_ == 0; + } + + private: + PointeeType *p_; }; |