diff --git a/enable_shared_from_this.html b/enable_shared_from_this.html index 028cf57..f04f312 100644 --- a/enable_shared_from_this.html +++ b/enable_shared_from_this.html @@ -2,21 +2,25 @@
- The header <boost/enable_shared_from_this.hpp> defines
- the class template enable_shared_from_this. It is used as a
- base class that allows a shared_ptr to the current
- object to be obtained from within a member function.
+ The header <boost/enable_shared_from_this.hpp>
defines
+ the class template enable_shared_from_this
. It is used as a
+ base class that allows a shared_ptr or
+ a weak_ptr to the current object to be obtained
+ from within a member function.
+
enable_shared_from_this<T>
defines two member functions
+ called shared_from_this
that return a shared_ptr<T>
+ and shared_ptr<T const>
, depending on constness, to this
.
+ It also defines two member functions called weak_from_this
that return
+ a corresponding weak_ptr
.
enable_shared_from_this<T> defines two member functions - called shared_from_this that return a shared_ptr<T> - and shared_ptr<T const>, depending on constness, to this.
#include <boost/enable_shared_from_this.hpp> @@ -41,7 +45,7 @@ int main() assert(!(p < q || q < p)); // p and q must share ownership }-
namespace boost { @@ -52,34 +56,55 @@ public: shared_ptr<T> shared_from_this(); shared_ptr<T const> shared_from_this() const; + + weak_ptr<T> weak_from_this() noexcept; + weak_ptr<T const> weak_from_this() const noexcept; } }-
template<class T> shared_ptr<T>
+ enable_shared_from_this<T>::shared_from_this();
template<class T> shared_ptr<T const>
+ enable_shared_from_this<T>::shared_from_this() const;
-- Requires: enable_shared_from_this<T> must be an - accessible base class of T. *this must be a subobject - of an instance t of type T . There must exist - at least one shared_ptr instance p that owns - t. + Requires:
enable_shared_from_this<T>
must be an + accessible base class ofT
.*this
must be a subobject + of an instancet
of typeT
.- Returns: A shared_ptr<T> instance r that shares - ownership with p. + Returns: If a
shared_ptr
instancep
that owns +t
exists, ashared_ptr<T>
instancer
that shares + ownership withp
.- Postconditions: r.get() == this. + Postconditions:
+r.get() == this
. ++ Throws:
bad_weak_ptr
when noshared_ptr
owns*this
.
$Date$
+template<class T> weak_ptr<T>
+ enable_shared_from_this<T>::weak_from_this() noexcept;
template<class T> weak_ptr<T const>
+ enable_shared_from_this<T>::weak_from_this() const noexcept;
+++ Requires:
+enable_shared_from_this<T>
must be an + accessible base class ofT
.*this
must be a subobject + of an instancet
of typeT
. ++ Returns: If a
+shared_ptr
instancep
that owns +t
exists or has existed in the past, aweak_ptr<T>
instance +r
that shares ownership withp
. Otherwise, an emptyweak_ptr
. +
- Copyright © 2002, 2003 by Peter Dimov. Distributed under the Boost Software License, Version - 1.0. See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt.
+ Copyright © 2002, 2003, 2015 by Peter Dimov. Distributed under the Boost Software License, Version + 1.0. See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/smart_ptr/enable_shared_from_this.hpp b/include/boost/smart_ptr/enable_shared_from_this.hpp index 3230f02..4e3f243 100644 --- a/include/boost/smart_ptr/enable_shared_from_this.hpp +++ b/include/boost/smart_ptr/enable_shared_from_this.hpp @@ -58,6 +58,16 @@ public: return p; } + weak_ptr