From f2541bb90af059680aa7036f315f052175999355 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 8 Apr 2015 03:09:47 +0000 Subject: Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2. --- libs/smart_ptr/enable_shared_from_this.html | 79 +++++++++++++++++++---------- 1 file changed, 52 insertions(+), 27 deletions(-) (limited to 'libs/smart_ptr/enable_shared_from_this.html') diff --git a/libs/smart_ptr/enable_shared_from_this.html b/libs/smart_ptr/enable_shared_from_this.html index 028cf57d7..f04f3126b 100644 --- a/libs/smart_ptr/enable_shared_from_this.html +++ b/libs/smart_ptr/enable_shared_from_this.html @@ -2,21 +2,25 @@ enable_shared_from_this - + -

boost.png (6897 bytes)enable_shared_from_this

+

boost.png (6897 bytes)enable_shared_from_this

Purpose

- 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.

Example

 #include <boost/enable_shared_from_this.hpp>
@@ -41,7 +45,7 @@ int main()
     assert(!(p < q || q < p)); // p and q must share ownership
 }
 
-

Synopsis

+

Synopsis

 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;

+

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 of T. *this must be a subobject + of an instance t of type T. +

+

+ Returns: If a shared_ptr instance p that owns + t exists, a shared_ptr<T> instance r that shares + ownership with p. +

+

+ Postconditions: r.get() == this. +

+

+ Throws: bad_weak_ptr when no shared_ptr owns *this.

+
+

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;

+

- Returns: A shared_ptr<T> instance r that shares - ownership with p. + 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.

- Postconditions: r.get() == this. + Returns: If a shared_ptr instance p that owns + t exists or has existed in the past, a weak_ptr<T> instance + r that shares ownership with p. Otherwise, an empty weak_ptr.

-

$Date$

+

- 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.

-- cgit v1.2.1