a mutex, which is a kind of resource that has to be specifically deallocated under such circumstances:
bool aMethod() { CountedPointer<Mutex> p = new Mutex() ;
if ( condition ) throw Exception() ; // no problemo! else return false ; }
The mode of operation is to create for each shared resource any number of counter pointer instances, which all share (point to) the same referent structure, which is the one tracking the reference count and taking care of the life-cycle of that resource.