From 11a046f6281c5e18996641c5346a589215c29829 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 19 Nov 2002 16:18:18 +0000 Subject: [PATCH] BOOST_ASSERTs added. [SVN r16324] --- include/boost/enable_shared_from_this.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/boost/enable_shared_from_this.hpp b/include/boost/enable_shared_from_this.hpp index 199725a..ae5d809 100644 --- a/include/boost/enable_shared_from_this.hpp +++ b/include/boost/enable_shared_from_this.hpp @@ -14,9 +14,10 @@ // http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html // -#include -#include #include +#include +#include +#include namespace boost { @@ -27,12 +28,16 @@ public: shared_ptr shared_from_this() { - return shared_ptr(weak_this); + shared_ptr p(weak_this); + BOOST_ASSERT(p.get() == this); + return p; } shared_ptr shared_from_this() const { - return shared_ptr(weak_this); + shared_ptr p(weak_this); + BOOST_ASSERT(p.get() == this); + return p; } #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS @@ -43,7 +48,8 @@ private: #endif - weak_ptr weak_this; + typedef T element_type; // for bcc 5.5.1 + weak_ptr weak_this; }; } // namespace boost