Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template< class T >
- struct Handle
- {
- typedef T subtype;
- T* item;
- Handle() : item( NULL ){}
- Handle( T* v ) : item( v ){ if( item ) item->Acquire(); }
- Handle( const Handle& h ) : item( h.item ){ if( item ) item->Acquire(); }
- ~Handle(){ if( item ){ item->Release(); item = NULL; } }
- Handle& operator = ( const Handle& h ){ if( item ) item->Release(); item = h.item; if( item ) item->Acquire(); return *this; }
- T* operator -> () const { return item; }
- T& operator * () const { return *item; }
- operator T* () const { return item; }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement