diff --git a/compatibility.htm b/compatibility.htm new file mode 100644 index 0000000..d520bd1 --- /dev/null +++ b/compatibility.htm @@ -0,0 +1,88 @@ + + +
+The February 2002 change to the Boost smart pointers introduced a number of + changes. Since the previous version of the smart pointers was in use for a long + time, it's useful to have a detailed list of what changed from a library user's + point of view.
+Note that for compilers that don't support member templates well enough, a + separate implementation is used that lacks many of the new features and is more + like the old version.
+Revised 1 February 2002
+Copyright 2002 Darin Adler. 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/enable_shared_from_this.html b/enable_shared_from_this.html new file mode 100644 index 0000000..c4caa25 --- /dev/null +++ b/enable_shared_from_this.html @@ -0,0 +1,95 @@ + + + + ![]() |
+
+ enable_shared_from_this.hpp+ |
+
+ |
+ 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. +
+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> +#include <boost/shared_ptr.hpp> +#include <cassert> + +class Y: public boost::enable_shared_from_this<Y> +{ +public: + + boost::shared_ptr<Y> f() + { + return shared_from_this(); + } +}; + +int main() +{ + boost::shared_ptr<Y> p(new Y); + boost::shared_ptr<Y> q = p->f(); + assert(p == q); + assert(!(p < q || q < p)); // p and q must share ownership +} ++
+namespace boost +{ + +template<class T> class enable_shared_from_this +{ +public: + + shared_ptr<T> shared_from_this(); + shared_ptr<T const> 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. +
++ Returns: A shared_ptr<T> instance r that shares + ownership with p. +
++ Postconditions: r.get() == this. +
+
+
+ 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.