23 ref_counted( void ) : _count( 0 ) {}
27 unsigned int add_ref( void ) { return ++_count; }
28 unsigned int release( void ) { return --_count; }
29 unsigned int count( void ) const { return _count; }
45 ref_ptr( T* ptr = 0 ) : _ptr( ptr )
50 ref_ptr( const ref_ptr & rptr ) : _ptr( rptr.get() )
55 ~ref_ptr( void ) { release(); }
58 T* get( void ) const { return _ptr; }
59 T* operator->( void ) const { return get(); }
60 T& operator*( void ) const { return *get(); }
62 bool operator!( void ) const { return get() == 0; }
63 bool operator==( const ref_ptr & rptr ) const { return *get() == *rptr;
65 bool operator<( const ref_ptr & rptr ) const { return *get() < *rptr; }
68 bool operator==( T* ptr ) const { return *get() == *ptr; }
69 bool operator<( T* ptr ) const { return *get() < *ptr; }
71 const ref_ptr & operator=( const ref_ptr & rptr )
80 T* operator=( T* ptr )
98 if( _ptr && 0 == _ptr->release() )
112 bool operator==( T* ptr, const ref_ptr< T > & rptr )
114 return *ptr == *rptr;
118 bool operator<( T* ptr, const ref_ptr< T > & rptr )
125 class Baz : public ref_counted {
134 static_cast<Bar *> (foo)->DoSomething; //{ dg-error "" } invalid cast