diff --git a/src/lib/handle.hpp b/src/lib/handle.hpp index e0dbaa661..cf2059923 100644 --- a/src/lib/handle.hpp +++ b/src/lib/handle.hpp @@ -68,27 +68,28 @@ namespace lib { */ template class Handle - : protected std::tr1::shared_ptr { + protected: + std::tr1::shared_ptr smPtr_; + public: - typedef std::tr1::shared_ptr SmP; /** by default create an Null handle. * Typically this is followed by activating * the handle by the managing service. */ Handle ( ) - : SmP() + : smPtr_() { } - Handle (Handle const& r) : SmP(r) {} - template Handle (shared_ptr const& r) : SmP(r) {} - template explicit Handle (weak_ptr const& wr) : SmP(wr) {} - template explicit Handle (std::auto_ptr & ar) : SmP(ar) {} + Handle (Handle const& r) : smPtr_(r.smPtr_) { } + template Handle (shared_ptr const& r) : smPtr_(r) { } + template explicit Handle (weak_ptr const& wr) : smPtr_(wr) { } + template explicit Handle (std::auto_ptr & ar) : smPtr_(ar) { } - Handle& operator= (Handle const& r) { SmP::operator= (r); return *this; } - template Handle& operator=(shared_ptr const& sr) { SmP::operator= (sr); return *this; } - template Handle& operator=(std::auto_ptr & ar) { SmP::operator= (ar); return *this; } + Handle& operator= (Handle const& r) { smPtr_ = r.smPtr_; return *this; } + template Handle& operator=(shared_ptr const& sr) { smPtr_ = sr; return *this; } + template Handle& operator=(std::auto_ptr & ar) { smPtr_ = ar; return *this; } /** deactivate this handle, so it isn't tied any longer @@ -97,14 +98,14 @@ namespace lib { * went out of scope, the associated implementation * reaches end-of-life. */ - void close () { SmP::reset(); } + void close () { smPtr_.reset(); } - typedef IMP* SmP::*__unspecified_bool_type; + typedef std::tr1::shared_ptr Handle::*__unspecified_bool_type; /** implicit conversion to "bool" */ - operator __unspecified_bool_type() const { return *this; } // never throws - bool operator! () const { return !SmP::get(); } // dito + operator __unspecified_bool_type() const { return &Handle::smPtr_; } // never throws + bool operator! () const { return !bool(smPtr_); } // dito @@ -119,15 +120,15 @@ namespace lib { Handle& activate (IMP* impl, DEL whenDead) { - SmP::reset (impl, whenDead); + smPtr_.reset (impl, whenDead); return *this; } IMP& impl() { - REQUIRE (SmP::get(), "Lifecycle-Error"); - return *(SmP::get()); + REQUIRE (smPtr_.get(), "Lifecycle-Error"); + return *(smPtr_.get()); } };