Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71686 - sandbox/block_ptr/libs/smart_ptr/doc
From: phil_at_[hidden]
Date: 2011-05-02 21:30:09


Author: pbouchard
Date: 2011-05-02 21:30:08 EDT (Mon, 02 May 2011)
New Revision: 71686
URL: http://svn.boost.org/trac/boost/changeset/71686

Log:
* Added documentation on explicit cyclic() function
Text files modified:
   sandbox/block_ptr/libs/smart_ptr/doc/tutorial.html | 24 +++++++++++++++++++++++-
   1 files changed, 23 insertions(+), 1 deletions(-)

Modified: sandbox/block_ptr/libs/smart_ptr/doc/tutorial.html
==============================================================================
--- sandbox/block_ptr/libs/smart_ptr/doc/tutorial.html (original)
+++ sandbox/block_ptr/libs/smart_ptr/doc/tutorial.html 2011-05-02 21:30:08 EDT (Mon, 02 May 2011)
@@ -88,7 +88,7 @@
   
   <h2><a name="advanced" id="advanced"></a>Advanced</h2>
 
- <p>When STL containers are made out of objects having members of type <i>block_ptr&#60;T&#62;</i> then it will be desirable to have all of the allocated nodes
+ <p>Firstly when STL containers are made out of objects having members of type <i>block_ptr&#60;T&#62;</i> then it will be desirable to have all of the allocated nodes
   and its members part of the same <i>set</i>. This way all of the newly allocated <i>block_ptr&#60;T&#62;</i> will be referring to the same <i>set</i> header.
   In order to do so, we must tell the container in question a new allocator that will be used to instantiate the nodes. This allocator is called:
   <i>block_allocator&#60;T&#62;</i>. For example:</p>
@@ -98,6 +98,28 @@
   c.push_back(make_block&#60;int&#62;(11));
   </pre>
 
+ <p>Secondly in the case where a cyclic set is being destroyed, in order to prevent <i>block_ptr</i>s member pointers from accessing an object that is already being
+ destroyed a function is provided to explicitly prevent such a scenario:</p>
+
+ <pre>
+ struct A
+ {
+ block_ptr&#60;A&#62; p;
+
+ void foo() {}
+
+ ~A()
+ {
+ if (! p.cyclic())
+ p->foo();
+ }
+ };
+
+ block_ptr&#60;A&#62; p;
+ p = make_block&#60;A&#62;();
+ p-&#62;p = p;
+ </pre>
+
   <h2><a name="caveat" id="caveat"></a>Caveat</h2>
   
   <p>Hierarchies with multiple inheritance without virtual tables will cause undefined behavior if a pointer to a derived class is assigned to a pointer of one


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