Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57950 - trunk/libs/smart_ptr
From: pdimov_at_[hidden]
Date: 2009-11-26 15:11:05


Author: pdimov
Date: 2009-11-26 15:11:05 EST (Thu, 26 Nov 2009)
New Revision: 57950
URL: http://svn.boost.org/trac/boost/changeset/57950

Log:
Fix enable_shared_from_this example. Refs #3404.
Text files modified:
   trunk/libs/smart_ptr/enable_shared_from_this.html | 14 +++++++++-----
   1 files changed, 9 insertions(+), 5 deletions(-)

Modified: trunk/libs/smart_ptr/enable_shared_from_this.html
==============================================================================
--- trunk/libs/smart_ptr/enable_shared_from_this.html (original)
+++ trunk/libs/smart_ptr/enable_shared_from_this.html 2009-11-26 15:11:05 EST (Thu, 26 Nov 2009)
@@ -29,20 +29,24 @@
                         and <STRONG>shared_ptr&lt;T const&gt;</STRONG>, depending on constness, to <STRONG>this</STRONG>.</P>
                 <h3><a name="Example">Example</a></h3>
                 <pre>
-class Y: public enable_shared_from_this&lt;Y&gt;
+#include &lt;boost/enable_shared_from_this.hpp&gt;
+#include &lt;boost/shared_ptr.hpp&gt;
+#include &lt;cassert&gt;
+
+class Y: public boost::enable_shared_from_this&lt;Y&gt;
 {
 public:
 
- shared_ptr&lt;Y&gt; f()
+ boost::shared_ptr&lt;Y&gt; f()
     {
         return shared_from_this();
     }
-}
+};
 
 int main()
 {
- shared_ptr&lt;Y&gt; p(new Y);
- shared_ptr&lt;Y&gt; q = p-&gt;f();
+ boost::shared_ptr&lt;Y&gt; p(new Y);
+ boost::shared_ptr&lt;Y&gt; q = p-&gt;f();
     assert(p == q);
     assert(!(p &lt; q || q &lt; p)); // p and q must share ownership
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk