mirror of
https://github.com/boostorg/ptr_container.git
synced 2026-02-24 04:12:13 +00:00
major doc update finnished
[SVN r33858]
This commit is contained in:
@@ -292,20 +292,28 @@ ul.auto-toc {
|
||||
<div class="section">
|
||||
<h1><a id="class-associative-ptr-container" name="class-associative-ptr-container">Class <tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt></a></h1>
|
||||
<p>This section describes all the common operations for all associative
|
||||
pointer containers (in addition to <tt class="docutils literal"><span class="pre">reversible_ptr_container</span></tt>):</p>
|
||||
pointer containers (in addition to <tt class="docutils literal"><span class="pre">reversible_ptr_container</span></tt>).</p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multimap_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multiset</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="http://www.boost.org/libs/range/doc/utility_class.html#iter_range">iterator_range</a></li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
@@ -521,7 +529,7 @@ given <tt class="docutils literal"><span class="pre">ptr_set<T></span></tt
|
||||
- Effects: returns the object with key ``key``
|
||||
|
||||
- Throws: ``bad_ptr_container_operation`` if the key does not exist -->
|
||||
<table class="docutils field-list" frame="void" id="pointer-container-requirements" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -8,33 +8,28 @@ Class ``associative_ptr_container``
|
||||
-------------------------------------
|
||||
|
||||
This section describes all the common operations for all associative
|
||||
pointer containers (in addition to ``reversible_ptr_container``):
|
||||
pointer containers (in addition to ``reversible_ptr_container``).
|
||||
|
||||
- ptr_map_adapter_
|
||||
- ptr_multimap_adapter_
|
||||
- ptr_map_
|
||||
- ptr_multimap_
|
||||
- ptr_set_adapter_
|
||||
- ptr_multiset_adapter_
|
||||
- ptr_set_
|
||||
- ptr_multiset_
|
||||
**Hierarchy:**
|
||||
|
||||
.. _ptr_map_adapter : ptr_map_adapter.html
|
||||
.. _ptr_multimap_adapter: ptr_multimap_adapter.html
|
||||
.. _ptr_map: ptr_map.html
|
||||
.. _ptr_multimap: ptr_multimap.html
|
||||
.. _ptr_set_adapter: ptr_set_adapter.html
|
||||
.. _ptr_multiset_adapter: ptr_multiset.html
|
||||
.. _ptr_set: ptr_set.html
|
||||
.. _ptr_multiset: ptr_multiset.html
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
- ``associative_ptr_container``
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**See also:**
|
||||
|
||||
- reversible_ptr_container__
|
||||
- `iterator_range <http://www.boost.org/libs/range/doc/utility_class.html#iter_range>`_
|
||||
|
||||
__ reversible_ptr_container.html
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
@@ -219,6 +214,9 @@ Semantics: algorithms
|
||||
|
||||
.. _`pointer container requirements`:
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -394,12 +394,12 @@ of the corresponding standard container.</p>
|
||||
insertion and deletion only invalidates the deleted
|
||||
element and elements following it; all elements before the inserted/deleted
|
||||
element remain valid.</p>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<hr><p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
<li><a class="reference" href="reference.html">reference</a></li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -113,11 +113,18 @@ insertion and deletion only invalidates the deleted
|
||||
element and elements following it; all elements before the inserted/deleted
|
||||
element remain valid.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
- `reference <reference.html>`_
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -308,7 +308,9 @@ ul.auto-toc {
|
||||
<pre class="literal-block">
|
||||
my_container.push_back( 0 ); // throws bad_ptr
|
||||
my_container.replace( an_iterator, 0 ); // throws bad_ptr
|
||||
my_container.insert( an_iterator, 0 ); // throws bad_ptr
|
||||
my_container.insert( an_iterator, 0 ); // throws bad_ptr
|
||||
std::auto_ptr<T> p( 0 );
|
||||
my_container.push_back( p ); // throws bad_ptr
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
@@ -342,7 +344,7 @@ ptr_vector<T> vec3( vec1 ); // compile time error: copy-constructo
|
||||
// a class that has no normal copy semantics
|
||||
class X : boost::noncopyable { public: X* clone() const; ... };
|
||||
|
||||
// this will be found by the library by argument dependent lookup
|
||||
// this will be found by the library by argument dependent lookup (ADL)
|
||||
X* new_clone( const X& x )
|
||||
{ return x.clone(); }
|
||||
|
||||
@@ -359,10 +361,12 @@ vec2.insert( vec2.end(), vec1.begin(), vec1.end() ); // inserting always means i
|
||||
class X { ... }; // assume 'X' is Clonable
|
||||
X x; // and 'X' can be stack-allocated
|
||||
ptr_list<X> list;
|
||||
list.push_back( x ); // clone 'x' and then insert the resulting pointer
|
||||
list.push_back( new_clone( x ); // do it manually
|
||||
list.push_back( new_clone( x ) ); // insert a clone
|
||||
list.push_back( new X ); // always give the pointer directly to the container to avoid leaks
|
||||
list.push_back( &x ); // don't do this!!!
|
||||
std::auto_ptr<X> p( new X );
|
||||
list.push_back( p ); // give up ownership
|
||||
BOOST_ASSERT( p.get() == 0 );
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
@@ -376,6 +380,8 @@ typedef ptr_deque<T>::auto_type auto_type;
|
||||
auto_type ptr = deq.release_back(); // remove back element from container and give up ownership
|
||||
auto_type ptr2 = deq.release( deq.begin() + 2 ); // use an iterator to determine the element to release
|
||||
ptr = deq.release_front(); // supported for 'ptr_list' and 'ptr_deque'
|
||||
|
||||
deq.push_back( ptr.release() ); // give ownership back to the container
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
@@ -389,6 +395,7 @@ ptr_list<X> list; ptr_vector<X> vec;
|
||||
list.transfer( list.begin(), vec.begin(), vec ); // make the first element of 'vec' the first element of 'list'
|
||||
vec.transfer( vec.end(), list.begin(), list.end(), list ); // put all the lists element into the vector
|
||||
</pre>
|
||||
<p>We can also transfer objects from <tt class="docutils literal"><span class="pre">ptr_container<Derived></span></tt> to <tt class="docutils literal"><span class="pre">ptr_container<Base</span></tt> without any problems.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id8" id="selected-test-files" name="selected-test-files"><span id="example-8"></span>8. Selected test files</a></h1>
|
||||
@@ -396,6 +403,8 @@ vec.transfer( vec.end(), list.begin(), list.end(), list ); // put all the lists
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name"><a class="reference" href="tutorial_example.html">tutorial.cpp</a>:</th><td class="field-body">A larger example with lots of comments.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name" colspan="2"><a class="reference" href="../test/incomplete_type_test.cpp">incomplete_type_test.cpp</a>:</th></tr>
|
||||
<tr><td> </td><td class="field-body">Shows how to implement the Composite pattern.</td>
|
||||
</tr>
|
||||
@@ -430,12 +439,12 @@ as view into other containers:
|
||||
|
||||
.. raw:: html
|
||||
:file: tut2.html -->
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<hr><p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
<li><a class="reference" href="reference.html">reference</a></li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -22,7 +22,9 @@ Some examples are given here and in the accompanying test files:
|
||||
|
||||
my_container.push_back( 0 ); // throws bad_ptr
|
||||
my_container.replace( an_iterator, 0 ); // throws bad_ptr
|
||||
my_container.insert( an_iterator, 0 ); // throws bad_ptr
|
||||
my_container.insert( an_iterator, 0 ); // throws bad_ptr
|
||||
std::auto_ptr<T> p( 0 );
|
||||
my_container.push_back( p ); // throws bad_ptr
|
||||
|
||||
.. _`Example 2`:
|
||||
|
||||
@@ -67,7 +69,7 @@ Some examples are given here and in the accompanying test files:
|
||||
// a class that has no normal copy semantics
|
||||
class X : boost::noncopyable { public: X* clone() const; ... };
|
||||
|
||||
// this will be found by the library by argument dependent lookup
|
||||
// this will be found by the library by argument dependent lookup (ADL)
|
||||
X* new_clone( const X& x )
|
||||
{ return x.clone(); }
|
||||
|
||||
@@ -88,10 +90,12 @@ Some examples are given here and in the accompanying test files:
|
||||
class X { ... }; // assume 'X' is Clonable
|
||||
X x; // and 'X' can be stack-allocated
|
||||
ptr_list<X> list;
|
||||
list.push_back( x ); // clone 'x' and then insert the resulting pointer
|
||||
list.push_back( new_clone( x ); // do it manually
|
||||
list.push_back( new_clone( x ) ); // insert a clone
|
||||
list.push_back( new X ); // always give the pointer directly to the container to avoid leaks
|
||||
list.push_back( &x ); // don't do this!!!
|
||||
std::auto_ptr<X> p( new X );
|
||||
list.push_back( p ); // give up ownership
|
||||
BOOST_ASSERT( p.get() == 0 );
|
||||
|
||||
|
||||
.. _`Example 6`:
|
||||
@@ -110,7 +114,8 @@ Some examples are given here and in the accompanying test files:
|
||||
auto_type ptr2 = deq.release( deq.begin() + 2 ); // use an iterator to determine the element to release
|
||||
ptr = deq.release_front(); // supported for 'ptr_list' and 'ptr_deque'
|
||||
|
||||
|
||||
deq.push_back( ptr.release() ); // give ownership back to the container
|
||||
|
||||
|
||||
.. _`Example 7`:
|
||||
|
||||
@@ -127,7 +132,8 @@ Some examples are given here and in the accompanying test files:
|
||||
//
|
||||
list.transfer( list.begin(), vec.begin(), vec ); // make the first element of 'vec' the first element of 'list'
|
||||
vec.transfer( vec.end(), list.begin(), list.end(), list ); // put all the lists element into the vector
|
||||
|
||||
|
||||
We can also transfer objects from ``ptr_container<Derived>`` to ``ptr_container<Base`` without any problems.
|
||||
|
||||
.. _`Example 8`:
|
||||
|
||||
@@ -136,6 +142,7 @@ Some examples are given here and in the accompanying test files:
|
||||
8. Selected test files
|
||||
++++++++++++++++++++++
|
||||
|
||||
:`tutorial.cpp <tutorial_example.html>`_: A larger example with lots of comments.
|
||||
:incomplete_type_test.cpp_: Shows how to implement the Composite pattern.
|
||||
:simple_test.cpp_: Shows how the usage of pointer container compares with a
|
||||
container of pointer pointers
|
||||
@@ -170,10 +177,18 @@ Some examples are given here and in the accompanying test files:
|
||||
.. raw:: html
|
||||
:file: tut2.html
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
- `reference <reference.html>`_
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ these references: <a class="reference" href="ptr_container.html#references">[11]
|
||||
<p>Storing a null-pointer among a list of pointers does not fit well into the Object Oriented paradigm.
|
||||
The most elegant design is to use the Null-Object Pattern where one basically makes a concrete
|
||||
class with dummy implementations of the virtual functions. See <a class="reference" href="ptr_container.html#references">[13]</a> for details.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
.. |Boost| image:: boost.png
|
||||
|
||||
===
|
||||
|
||||
FAQ
|
||||
===
|
||||
|
||||
@@ -98,6 +98,9 @@ Storing a null-pointer among a list of pointers does not fit well into the Objec
|
||||
The most elegant design is to use the Null-Object Pattern where one basically makes a concrete
|
||||
class with dummy implementations of the virtual functions. See `[13] <ptr_container.html#references>`_ for details.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -414,12 +414,12 @@ your OO-code still does not need to worry about null-pointers.</p>
|
||||
</ul>
|
||||
<p>Finally you might end up in a situation where not even the Null Object can help
|
||||
you. That is when you truly need <tt class="docutils literal"><span class="pre">container<</span> <span class="pre">nullable<T></span> <span class="pre">></span></tt>.</p>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<hr><p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
<li><a class="reference" href="reference.html">reference</a></li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -142,10 +142,18 @@ You might want to read
|
||||
Finally you might end up in a situation where not even the Null Object can help
|
||||
you. That is when you truly need ``container< nullable<T> >``.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
- `reference <reference.html>`_
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -334,16 +334,16 @@ and functions <tt class="docutils literal"><span class="pre">new_clone()</span><
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre"><boost/ptr_container/exception.hpp></span></tt></td>
|
||||
<td><dl class="first last docutils">
|
||||
<dt>classes <tt class="docutils literal"><span class="pre">bad_ptr_container_operation</span></tt>, <tt class="docutils literal"><span class="pre">bad_index</span></tt></dt>
|
||||
<dd>and <tt class="docutils literal"><span class="pre">bad_pointer</span></tt></dd>
|
||||
<dt>classes <a class="reference" href="reference.html#exception-classes">bad_ptr_container_operation</a>, <a class="reference" href="reference.html#exception-classes">bad_index</a></dt>
|
||||
<dd>and <a class="reference" href="reference.html#exception-classes">bad_pointer</a></dd>
|
||||
</dl>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre"><boost/ptr_container/indirect_fun.hpp></span></tt></td>
|
||||
<td>class <tt class="docutils literal"><span class="pre">indirect_fun</span></tt></td>
|
||||
<td>class <a class="reference" href="indirect_fun.html">indirect_fun</a></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre"><boost/ptr_container/nullable.hpp></span></tt></td>
|
||||
<td>class <tt class="docutils literal"><span class="pre">nullable</span></tt></td>
|
||||
<td>class <a class="reference" href="reference.html#class-nullable">nullable</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -352,7 +352,7 @@ and functions <tt class="docutils literal"><span class="pre">new_clone()</span><
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
<li><a class="reference" href="reference.html">reference</a></li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -34,21 +34,30 @@ Library headers
|
||||
|
||||
``<boost/ptr_container/ptr_map_adapter.hpp>`` classes `ptr_map_adapter <ptr_map_adapter.html>`_ and `ptr_multimap_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
``<boost/ptr_container/exception.hpp>`` classes ``bad_ptr_container_operation``, ``bad_index``
|
||||
and ``bad_pointer``
|
||||
``<boost/ptr_container/indirect_fun.hpp>`` class ``indirect_fun``
|
||||
``<boost/ptr_container/exception.hpp>`` classes `bad_ptr_container_operation`_, `bad_index`_
|
||||
and `bad_pointer`_
|
||||
``<boost/ptr_container/indirect_fun.hpp>`` class `indirect_fun`_
|
||||
|
||||
``<boost/ptr_container/nullable.hpp>`` class ``nullable``
|
||||
``<boost/ptr_container/nullable.hpp>`` class `nullable`_
|
||||
======================================================= =============================================================
|
||||
|
||||
.. _`heap_clone_allocator`: reference.html#the-clone-allocator-concept
|
||||
.. _`view_clone_allocator`: reference.html#the-clone-allocator-concept
|
||||
.. _`bad_ptr_container_operation`: reference.html#exception-classes
|
||||
.. _`bad_index`: reference.html#exception-classes
|
||||
.. _`bad_pointer`: reference.html#exception-classes
|
||||
.. _`nullable`: reference.html#class-nullable
|
||||
.. _`indirect_fun`: indirect_fun.html
|
||||
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
- `reference <reference.html>`_
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ namespace boost
|
||||
|
||||
} // namespace 'boost'
|
||||
</pre>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -125,6 +125,9 @@ first operation is expanded inline.
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -293,12 +293,19 @@ ul.auto-toc {
|
||||
<h1><a id="class-ptr-array" name="class-ptr-array">Class <tt class="docutils literal"><span class="pre">ptr_array</span></tt></a></h1>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_array<T,size></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">boost::array<void*,size></span></tt>
|
||||
to store the pointers. The class is useful when there is no requirement
|
||||
of dynamic expansion and when absolute no overhead is tolerable.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
of dynamic expansion and when no overhead is tolerable.</p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_array</span></tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -545,7 +552,7 @@ namespace boost
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -9,17 +9,18 @@ Class ``ptr_array``
|
||||
|
||||
A ``ptr_array<T,size>`` is a pointer container that uses an underlying ``boost::array<void*,size>``
|
||||
to store the pointers. The class is useful when there is no requirement
|
||||
of dynamic expansion and when absolute no overhead is tolerable.
|
||||
of dynamic expansion and when no overhead is tolerable.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- ptr_sequence_adapter_
|
||||
- ptr_vector_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _ptr_sequence_adapter: ptr_sequence_adapter.html
|
||||
.. _ptr_vector: ptr_vector.html
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- ``ptr_array``
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -250,5 +251,9 @@ Semantics: pointer container requirements
|
||||
|
||||
- Exception safety: Nothrow guarantee
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="Docutils 0.3.10: http://docutils.sourceforge.net/" />
|
||||
<title>Boost Pointer Container Library</title>
|
||||
<meta name="author" content="Thorsten Ottosen" />
|
||||
<meta name="date" content="3rd of May 2005" />
|
||||
<meta name="date" content="29th of April 2006" />
|
||||
<meta name="copyright" content="Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt)." />
|
||||
<style type="text/css">
|
||||
|
||||
@@ -299,11 +299,11 @@ ul.auto-toc {
|
||||
<tr><th class="docinfo-name">Author:</th>
|
||||
<td>Thorsten Ottosen</td></tr>
|
||||
<tr><th class="docinfo-name">Contact:</th>
|
||||
<td><a class="first last reference" href="mailto:nesotto@cs.aau.dk">nesotto@cs.aau.dk</a></td></tr>
|
||||
<tr class="field"><th class="docinfo-name">organizations:</th><td class="field-body"><a class="reference" href="http://www.cs.aau.dk">Department of Computer Science</a>, Aalborg University, and <a class="reference" href="http://www.dezide.com">Dezide Aps</a></td>
|
||||
<td><a class="first reference" href="mailto:nesotto@cs.aau.dk">nesotto@cs.aau.dk</a> or <a class="last reference" href="mailto:tottosen@dezide.com">tottosen@dezide.com</a></td></tr>
|
||||
<tr class="field"><th class="docinfo-name">Organizations:</th><td class="field-body"><a class="reference" href="http://www.cs.aau.dk">Department of Computer Science</a>, Aalborg University, and <a class="reference" href="http://www.dezide.com">Dezide Aps</a></td>
|
||||
</tr>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>3rd of May 2005</td></tr>
|
||||
<td>29th of April 2006</td></tr>
|
||||
<tr><th class="docinfo-name">Copyright:</th>
|
||||
<td>Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt</a>).</td></tr>
|
||||
</tbody>
|
||||
@@ -323,6 +323,7 @@ and designs for dealing with OO specific problems</p>
|
||||
<li><a class="reference" href="examples.html">Examples</a></li>
|
||||
<li><a class="reference" href="headers.html">Library headers</a></li>
|
||||
<li><a class="reference" href="faq.html">FAQ</a></li>
|
||||
<li><a class="reference" href="#upgrading-from-boost-v-1-33">Upgrading from Boost v. 1.33.*</a></li>
|
||||
<li><a class="reference" href="#acknowledgements">Acknowledgements</a></li>
|
||||
<li><a class="reference" href="#references">References</a></li>
|
||||
</ul>
|
||||
@@ -354,7 +355,10 @@ to make a container of pointer pointers like <tt class="docutils literal"><span
|
||||
This approach is suboptimal if</p>
|
||||
<ol class="arabic simple">
|
||||
<li>the stored objects are not shared, but owned exclusively, or</li>
|
||||
<li>the overhead implied by pointer pointers is inappropriate</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="2">
|
||||
<li>the overhead implied by smart pointers is inappropriate</li>
|
||||
</ol>
|
||||
<p>This library therefore provides standard-like containers that are for storing
|
||||
heap-allocated or <a class="reference" href="reference.html#the-clonable-concept">cloned</a> objects (or in case of a map, the mapped object must be
|
||||
@@ -366,19 +370,86 @@ to solve the so-called
|
||||
<p>The advantages of pointer containers are</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Exception-safe pointer storage and manipulation.</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="2">
|
||||
<li>Notational convenience compared to the use of containers of pointers.</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="3">
|
||||
<li>Can be used for types that are neither Assignable nor Copy Constructible.</li>
|
||||
<li>No memory-overhead as containers of pointer pointers can have (see <a class="footnote-reference" href="#id21" id="id2" name="id2">[11]</a> and <a class="footnote-reference" href="#id23" id="id3" name="id3">[12]</a>).</li>
|
||||
<li>Usually faster than using containers of pointer pointers (see <a class="footnote-reference" href="#id21" id="id4" name="id4">[11]</a> and <a class="footnote-reference" href="#id23" id="id5" name="id5">[12]</a>).</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="4">
|
||||
<li>No memory-overhead as containers of smart pointers can have (see <a class="footnote-reference" href="#id22" id="id2" name="id2">[11]</a> and <a class="footnote-reference" href="#id24" id="id3" name="id3">[12]</a>).</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="5">
|
||||
<li>Usually faster than using containers of smart pointers (see <a class="footnote-reference" href="#id22" id="id4" name="id4">[11]</a> and <a class="footnote-reference" href="#id24" id="id5" name="id5">[12]</a>).</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="6">
|
||||
<li>The interface is slightly changed towards the domain of pointers
|
||||
instead of relying on the normal value-based interface. For example,
|
||||
now it is possible for <tt class="docutils literal"><span class="pre">pop_back()</span></tt> to return the removed element.</li>
|
||||
<li>Propagates constness s.t. one cannot modify the objects via a <tt class="docutils literal"><span class="pre">const_iterator</span></tt></li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="7">
|
||||
<li>Propagates constness s.t. one cannot modify the objects via a <tt class="docutils literal"><span class="pre">const_iterator</span></tt>.</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="8">
|
||||
<li>Built-in support for deep-copy semantics via the <a class="reference" href="reference.html#the-clonable-concept">The Clobable Concept</a></li>
|
||||
</ol>
|
||||
<p>The disadvantages are</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Less flexible than containers of smart pointers like <a class="reference" href="../../smart_ptr/shared_ptr.htm">boost::shared_ptr</a></li>
|
||||
</ol>
|
||||
<p>When you do need shared semantics, this library is not what you need.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="upgrading-from-boost-v-1-33" name="upgrading-from-boost-v-1-33">Upgrading from Boost v. <tt class="docutils literal"><span class="pre">1.33.*</span></tt></a></h1>
|
||||
<p>If you upgrade from one of these versions of Boost, then there has been one
|
||||
major interface change: map iterators now mimic iterators from <tt class="docutils literal"><span class="pre">std::map</span></tt>.
|
||||
Previously you may have written</p>
|
||||
<pre class="literal-block">
|
||||
for( boost::ptr_map<std::string,T>::iterator i = m.begin(), e = m.end();
|
||||
i != e; ++i )
|
||||
{
|
||||
std::cout << "key:" << i.key();
|
||||
std::cout << "value:" << *i;
|
||||
i->foo(); // call T::foo()
|
||||
}
|
||||
</pre>
|
||||
<p>and this now needs to be converted into</p>
|
||||
<pre class="literal-block">
|
||||
for( boost::ptr_map<std::string,T>::iterator i = m.begin(), e = m.end();
|
||||
i != e; ++i )
|
||||
{
|
||||
std::cout << "key:" << i->first;
|
||||
std::cout << "value:" << *i->second;
|
||||
i->second->foo(); // call T::foo()
|
||||
}
|
||||
</pre>
|
||||
<p>Apart from the above change, the library now also introduces</p>
|
||||
<ul>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">std::auto_ptr<T></span></tt> overloads:</p>
|
||||
<pre class="literal-block">
|
||||
std::auto_ptr<T> p( new T );
|
||||
container.push_back( p );
|
||||
</pre>
|
||||
</li>
|
||||
<li><p class="first">Derived-to-Base conversion in <tt class="docutils literal"><span class="pre">transfer()</span></tt>:</p>
|
||||
<pre class="literal-block">
|
||||
boost::ptr_vector<Base> vec;
|
||||
boost::ptr_list<Derived> list;
|
||||
...
|
||||
vec.transfer( vec.begin(), list ); // now ok
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Also note that <a class="reference" href="../../assign/index.html">Boost.Assign</a> introduces better support
|
||||
for pointer containers.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="acknowledgements" name="acknowledgements">Acknowledgements</a></h1>
|
||||
@@ -402,89 +473,89 @@ which is used internally</li>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="references" name="references">References</a></h1>
|
||||
<table class="docutils footnote" frame="void" id="id6" rules="none">
|
||||
<table class="docutils footnote" frame="void" id="id7" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id6">[1]</a></td><td>Matt Austern: <a class="reference" href="http://www.cuj.com/documents/s=7990/cujcexp1910austern/">"The Standard Librarian: Containers of Pointers"</a> , C/C++ Users Journal Experts Forum.</td></tr>
|
||||
<tr><td class="label"><a name="id7">[1]</a></td><td>Matt Austern: <a class="reference" href="http://www.cuj.com/documents/s=7990/cujcexp1910austern/">"The Standard Librarian: Containers of Pointers"</a> , C/C++ Users Journal Experts Forum.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id8" rules="none">
|
||||
<table class="docutils footnote" frame="void" id="id9" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id8">[2]</a></td><td>Bjarne Stroustrup, "The C++ Programming Language", <a class="reference" href="http://www.research.att.com/~bs/3rd_safe.pdf">Appendix E: "Standard-Library Exception Safety"</a></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id10" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id10">[3]</a></td><td>Herb Sutter, "Exceptional C++".</td></tr>
|
||||
<tr><td class="label"><a name="id9">[2]</a></td><td>Bjarne Stroustrup, "The C++ Programming Language", <a class="reference" href="http://www.research.att.com/~bs/3rd_safe.pdf">Appendix E: "Standard-Library Exception Safety"</a></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id11" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id11">[4]</a></td><td>Herb Sutter, "More Exceptional C++".</td></tr>
|
||||
<tr><td class="label"><a name="id11">[3]</a></td><td>Herb Sutter, "Exceptional C++".</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id12" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id12">[5]</a></td><td>Kevlin Henney: <a class="reference" href="http://www.cuj.com/documents/s=7986/cujcexp2002henney/henney.htm">"From Mechanism to Method: The Safe Stacking of Cats"</a> , C++ Experts Forum, February 2002.</td></tr>
|
||||
<tr><td class="label"><a name="id12">[4]</a></td><td>Herb Sutter, "More Exceptional C++".</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id14" rules="none">
|
||||
<table class="docutils footnote" frame="void" id="id13" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id14">[6]</a></td><td>Some of the few earlier attempts of pointer containers I have seen are the rather interesting <a class="reference" href="http://www.ntllib.org/asp.html">NTL</a> and the
|
||||
<a class="reference" href="http://ootips.org/yonat/4dev/pointainer.h">pointainer</a>.
|
||||
As of this writing both libraries are not exceptions-safe and can leak.</td></tr>
|
||||
<tr><td class="label"><a name="id13">[5]</a></td><td>Kevlin Henney: <a class="reference" href="http://www.cuj.com/documents/s=7986/cujcexp2002henney/henney.htm">"From Mechanism to Method: The Safe Stacking of Cats"</a> , C++ Experts Forum, February 2002.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id15" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id15">[7]</a></td><td>INTERNATIONAL STANDARD, Programming languages --- C++, ISO/IEC 14882, 1998. See section 23 in particular.</td></tr>
|
||||
<tr><td class="label"><a name="id15">[6]</a></td><td>Some of the few earlier attempts of pointer containers I have seen are the rather interesting <a class="reference" href="http://www.ntllib.org/asp.html">NTL</a> and the
|
||||
<a class="reference" href="http://ootips.org/yonat/4dev/pointainer.h">pointainer</a>.
|
||||
As of this writing both libraries are not exceptions-safe and can leak.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id16" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id16">[8]</a></td><td>C++ Standard Library Closed Issues List (Revision 27),
|
||||
<tr><td class="label"><a name="id16">[7]</a></td><td>INTERNATIONAL STANDARD, Programming languages --- C++, ISO/IEC 14882, 1998. See section 23 in particular.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id17" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id17">[8]</a></td><td>C++ Standard Library Closed Issues List (Revision 27),
|
||||
Item 218, <a class="reference" href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-closed.html#218">Algorithms do not use binary predicate objects for default comparisons</a>.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id18" rules="none">
|
||||
<table class="docutils footnote" frame="void" id="id19" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id18">[9]</a></td><td>C++ Standard Library Active Issues List (Revision 27),
|
||||
<tr><td class="label"><a name="id19">[9]</a></td><td>C++ Standard Library Active Issues List (Revision 27),
|
||||
Item 226, <a class="reference" href="http://gcc.gnu.org/onlinedocs/libstdc++/ext/lwg-active.html#226">User supplied specializations or overloads of namespace std function templates</a>.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id20" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id20">[10]</a></td><td>Harald Nowak, "A remove_if for vector", C/C++ Users Journal, July 2001.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id21" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id21">[11]</a></td><td><em>(<a class="fn-backref" href="#id2">1</a>, <a class="fn-backref" href="#id4">2</a>)</em> Boost smart pointer <a class="reference" href="http://www.boost.org/libs/smart_ptr/smarttests.htm">timings</a></td></tr>
|
||||
<tr><td class="label"><a name="id21">[10]</a></td><td>Harald Nowak, "A remove_if for vector", C/C++ Users Journal, July 2001.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id23" rules="none">
|
||||
<table class="docutils footnote" frame="void" id="id22" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id23">[12]</a></td><td><em>(<a class="fn-backref" href="#id3">1</a>, <a class="fn-backref" href="#id5">2</a>)</em> <a class="reference" href="http://www.ntllib.org/asp.html">NTL</a>: Array vs std::vector and boost::shared_ptr</td></tr>
|
||||
<tr><td class="label"><a name="id22">[11]</a></td><td><em>(<a class="fn-backref" href="#id2">1</a>, <a class="fn-backref" href="#id4">2</a>)</em> Boost smart pointer <a class="reference" href="http://www.boost.org/libs/smart_ptr/smarttests.htm">timings</a></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="id24" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id24">[13]</a></td><td>Kevlin Henney, <a class="reference" href="http://www.two-sdg.demon.co.uk/curbralan/papers/europlop/NullObject.pdf">Null Object</a>, 2002.</td></tr>
|
||||
<tr><td class="label"><a name="id24">[12]</a></td><td><em>(<a class="fn-backref" href="#id3">1</a>, <a class="fn-backref" href="#id5">2</a>)</em> <a class="reference" href="http://www.ntllib.org/asp.html">NTL</a>: Array vs std::vector and boost::shared_ptr</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<table class="docutils footnote" frame="void" id="id25" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="id25">[13]</a></td><td>Kevlin Henney, <a class="reference" href="http://www.two-sdg.demon.co.uk/curbralan/papers/europlop/NullObject.pdf">Null Object</a>, 2002.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
|
||||
:Authors: Thorsten Ottosen
|
||||
:Contact: nesotto@cs.aau.dk
|
||||
:organizations: `Department of Computer Science`_, Aalborg University, and `Dezide Aps`_
|
||||
:date: 3rd of May 2005
|
||||
:Contact: nesotto@cs.aau.dk or tottosen@dezide.com
|
||||
:Organizations: `Department of Computer Science`_, Aalborg University, and `Dezide Aps`_
|
||||
:date: 29th of April 2006
|
||||
:Copyright: Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
|
||||
|
||||
__ http://www.boost.org/LICENSE_1_0.txt
|
||||
@@ -35,6 +35,7 @@ and designs for dealing with OO specific problems
|
||||
* Examples_
|
||||
* `Library headers`_
|
||||
* FAQ_
|
||||
* `Upgrading from Boost v. 1.33.*`_
|
||||
* Acknowledgements_
|
||||
* References_
|
||||
|
||||
@@ -85,7 +86,10 @@ to make a container of pointer pointers like ``boost::shared_ptr``.
|
||||
This approach is suboptimal if
|
||||
|
||||
1. the stored objects are not shared, but owned exclusively, or
|
||||
2. the overhead implied by pointer pointers is inappropriate
|
||||
|
||||
..
|
||||
|
||||
2. the overhead implied by smart pointers is inappropriate
|
||||
|
||||
This library therefore provides standard-like containers that are for storing
|
||||
heap-allocated or `cloned <reference.html#the-clonable-concept>`_ objects (or in case of a map, the mapped object must be
|
||||
@@ -99,19 +103,88 @@ to solve the so-called
|
||||
The advantages of pointer containers are
|
||||
|
||||
1. Exception-safe pointer storage and manipulation.
|
||||
|
||||
..
|
||||
|
||||
2. Notational convenience compared to the use of containers of pointers.
|
||||
|
||||
..
|
||||
|
||||
3. Can be used for types that are neither Assignable nor Copy Constructible.
|
||||
4. No memory-overhead as containers of pointer pointers can have (see [11]_ and [12]_).
|
||||
5. Usually faster than using containers of pointer pointers (see [11]_ and [12]_).
|
||||
|
||||
..
|
||||
|
||||
4. No memory-overhead as containers of smart pointers can have (see [11]_ and [12]_).
|
||||
|
||||
..
|
||||
|
||||
5. Usually faster than using containers of smart pointers (see [11]_ and [12]_).
|
||||
|
||||
..
|
||||
|
||||
6. The interface is slightly changed towards the domain of pointers
|
||||
instead of relying on the normal value-based interface. For example,
|
||||
now it is possible for ``pop_back()`` to return the removed element.
|
||||
7. Propagates constness s.t. one cannot modify the objects via a ``const_iterator``
|
||||
|
||||
..
|
||||
|
||||
7. Propagates constness s.t. one cannot modify the objects via a ``const_iterator``.
|
||||
|
||||
..
|
||||
|
||||
8. Built-in support for deep-copy semantics via the `The Clobable Concept`__
|
||||
|
||||
.. __: reference.html#the-clonable-concept
|
||||
|
||||
The disadvantages are
|
||||
|
||||
1. Less flexible than containers of smart pointers like `boost::shared_ptr <../../smart_ptr/shared_ptr.htm>`_
|
||||
|
||||
When you do need shared semantics, this library is not what you need.
|
||||
|
||||
====================================
|
||||
Upgrading from Boost v. ``1.33.*``
|
||||
====================================
|
||||
|
||||
If you upgrade from one of these versions of Boost, then there has been one
|
||||
major interface change: map iterators now mimic iterators from ``std::map``.
|
||||
Previously you may have written ::
|
||||
|
||||
for( boost::ptr_map<std::string,T>::iterator i = m.begin(), e = m.end();
|
||||
i != e; ++i )
|
||||
{
|
||||
std::cout << "key:" << i.key();
|
||||
std::cout << "value:" << *i;
|
||||
i->foo(); // call T::foo()
|
||||
}
|
||||
|
||||
and this now needs to be converted into ::
|
||||
|
||||
for( boost::ptr_map<std::string,T>::iterator i = m.begin(), e = m.end();
|
||||
i != e; ++i )
|
||||
{
|
||||
std::cout << "key:" << i->first;
|
||||
std::cout << "value:" << *i->second;
|
||||
i->second->foo(); // call T::foo()
|
||||
}
|
||||
|
||||
Apart from the above change, the library now also introduces
|
||||
|
||||
- ``std::auto_ptr<T>`` overloads::
|
||||
|
||||
std::auto_ptr<T> p( new T );
|
||||
container.push_back( p );
|
||||
|
||||
- Derived-to-Base conversion in ``transfer()``::
|
||||
|
||||
boost::ptr_vector<Base> vec;
|
||||
boost::ptr_list<Derived> list;
|
||||
...
|
||||
vec.transfer( vec.begin(), list ); // now ok
|
||||
|
||||
Also note that `Boost.Assign <../../assign/index.html>`_ introduces better support
|
||||
for pointer containers.
|
||||
|
||||
================
|
||||
Acknowledgements
|
||||
================
|
||||
@@ -180,5 +253,9 @@ __ http://www.two-sdg.demon.co.uk/curbralan/papers/europlop/NullObject.pdf
|
||||
.. _pointainer: http://ootips.org/yonat/4dev/pointainer.h
|
||||
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -293,10 +293,18 @@ ul.auto-toc {
|
||||
<h1><a id="class-ptr-deque" name="class-ptr-deque">Class <tt class="docutils literal"><span class="pre">ptr_deque</span></tt></a></h1>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_deque<T></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">std:deque<void*></span></tt>
|
||||
to store the pointers.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_deque</span></tt></li>
|
||||
<li><a class="reference" href="ptr_array.html">ptr_array</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -444,7 +452,7 @@ namespace boost
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,13 +10,16 @@ Class ``ptr_deque``
|
||||
A ``ptr_deque<T>`` is a pointer container that uses an underlying ``std:deque<void*>``
|
||||
to store the pointers.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- ptr_sequence_adapter_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _ptr_map: ptr_map.html
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- ``ptr_deque``
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -165,6 +168,9 @@ Semantics: pointer container requirements
|
||||
|
||||
- Exception safety: Nothrow guarantee
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -293,10 +293,18 @@ ul.auto-toc {
|
||||
<h1><a id="class-ptr-list" name="class-ptr-list">Class <tt class="docutils literal"><span class="pre">ptr_list</span></tt></a></h1>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_list<T></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">std:list<void*></span></tt>
|
||||
to store the pointers.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_list</span></tt></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_array.html">ptr_array</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -418,7 +426,7 @@ namespace boost
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,15 +10,17 @@ Class ``ptr_list``
|
||||
A ``ptr_list<T>`` is a pointer container that uses an underlying ``std:list<void*>``
|
||||
to store the pointers.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- ptr_sequence_adapter_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _ptr_array: ptr_array.html
|
||||
.. _`ptr_sequence_adapter`: ptr_sequence_adapter.html
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- ``ptr_list``
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
@@ -142,6 +144,9 @@ Semantics: list operations
|
||||
|
||||
- Throws: nothing
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -292,14 +292,25 @@ ul.auto-toc {
|
||||
<h2 class="subtitle" id="class-ptr-map">Class <tt class="docutils literal"><span class="pre">ptr_map</span></tt></h2>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_map<Key,T></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">std::map<Key,void*></span></tt>
|
||||
to store the pointers.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="reference.html#map-iterator-operations">new map iterators</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_map</span></tt></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- class `indirect_fun <indirect_fun.html>`_ -->
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
@@ -331,7 +342,7 @@ namespace boost
|
||||
|
||||
} // namespace 'boost'
|
||||
</pre>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,18 +10,21 @@ Class ``ptr_map``
|
||||
A ``ptr_map<Key,T>`` is a pointer container that uses an underlying ``std::map<Key,void*>``
|
||||
to store the pointers.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_map_adapter_
|
||||
- `new map iterators <reference.html#map-iterator-operations>`_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _associative_ptr_container: associative_ptr_container.html
|
||||
.. _ptr_map_adapter: ptr_map_adapter.html
|
||||
.. class `indirect_fun <indirect_fun.html>`_
|
||||
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- ``ptr_map``
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -58,6 +61,9 @@ to store the pointers.
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -294,12 +294,24 @@ ul.auto-toc {
|
||||
<p>This class is used to build custom pointer containers with
|
||||
an underlying map-like container. The interface of the class is an extension
|
||||
of the interface from <tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_map_adapter</span></tt></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="reference.html#map-iterator-operations">new map iterators</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -378,7 +390,7 @@ a_pointer->second->foo();
|
||||
map_type::const_pointer a_cpointer = &*const_begin(m);
|
||||
</pre>
|
||||
<p>The difference compared to <tt class="docutils literal"><span class="pre">std::map<Key,T*></span></tt> is that constness
|
||||
is propagated to the pointer (that is, to <tt class="docutils literal"><span class="pre">second</span></tt>).</p>
|
||||
is propagated to the pointer (that is, to <tt class="docutils literal"><span class="pre">second</span></tt>) in <tt class="docutils literal"><span class="pre">const_itertor</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="semantics-modifiers" name="semantics-modifiers"><span id="modifiers"></span>Semantics: modifiers</a></h2>
|
||||
@@ -470,7 +482,7 @@ An object is only transferred if no equivalent object exists.</li>
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -11,17 +11,22 @@ This class is used to build custom pointer containers with
|
||||
an underlying map-like container. The interface of the class is an extension
|
||||
of the interface from ``associative_ptr_container``.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_map_
|
||||
- `new map iterators <reference.html#map-iterator-operations>`_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _associative_ptr_container: associative_ptr_container.html
|
||||
.. _ptr_map: ptr_map.html
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- ``ptr_map_adapter``
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
@@ -106,7 +111,7 @@ However, one may still write ::
|
||||
map_type::const_pointer a_cpointer = &*const_begin(m);
|
||||
|
||||
The difference compared to ``std::map<Key,T*>`` is that constness
|
||||
is propagated to the pointer (that is, to ``second``).
|
||||
is propagated to the pointer (that is, to ``second``) in ``const_itertor``.
|
||||
|
||||
.. _`modifiers`:
|
||||
|
||||
@@ -187,6 +192,9 @@ Semantics: pointer container requirements
|
||||
|
||||
- Effects: ``return transfer( from.begin(), from.end(), from );``.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -292,12 +292,24 @@ ul.auto-toc {
|
||||
<h2 class="subtitle" id="class-ptr-multimap">Class <tt class="docutils literal"><span class="pre">ptr_multimap</span></tt></h2>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_multimap<Key,T></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">std::multimap<Key,void*></span></tt>
|
||||
to store the pointers.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multimap_adapter</a></li>
|
||||
<li><a class="reference" href="reference.html#map-iterator-operations">new map iterators</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multimap</span></tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
|
||||
@@ -10,12 +10,22 @@ Class ``ptr_multimap``
|
||||
A ``ptr_multimap<Key,T>`` is a pointer container that uses an underlying ``std::multimap<Key,void*>``
|
||||
to store the pointers.
|
||||
|
||||
**See also:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_multimap_adapter_
|
||||
- `new map iterators <reference.html#map-iterator-operations>`_
|
||||
**Hierarchy:**
|
||||
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- ``ptr_multimap``
|
||||
|
||||
**Navigate:**
|
||||
|
||||
|
||||
@@ -294,12 +294,24 @@ ul.auto-toc {
|
||||
<p>This class is used to build custom pointer containers with
|
||||
an underlying multimap-like container. The interface of the class is an extension
|
||||
of the interface from <tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multi_map_adapter</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
<li><a class="reference" href="ptr_container.html#map-iterator-operations">new map iterators</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -374,7 +386,7 @@ a_pointer->second->foo();
|
||||
map_type::const_pointer a_cpointer = &*const_begin(m);
|
||||
</pre>
|
||||
<p>The difference compared to <tt class="docutils literal"><span class="pre">std::map<Key,T*></span></tt> is that constness
|
||||
is propagated to the pointer (that is, to <tt class="docutils literal"><span class="pre">second</span></tt>).</p>
|
||||
is propagated to the pointer (that is, to <tt class="docutils literal"><span class="pre">second</span></tt>) in <tt class="docutils literal"><span class="pre">const_itertor</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="semantics-modifiers" name="semantics-modifiers"><span id="modifiers"></span>Semantics: modifiers</a></h2>
|
||||
@@ -454,7 +466,7 @@ is propagated to the pointer (that is, to <tt class="docutils literal"><span cla
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -11,17 +11,21 @@ This class is used to build custom pointer containers with
|
||||
an underlying multimap-like container. The interface of the class is an extension
|
||||
of the interface from ``associative_ptr_container``.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_multimap_
|
||||
- `new map iterators`__
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _associative_ptr_container: associative_ptr_container.html
|
||||
.. _ptr_multimap: ptr_multimap.html
|
||||
__ ptr_container.html#map-iterator-operations
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- ``ptr_multi_map_adapter``
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -102,7 +106,7 @@ However, one may still write ::
|
||||
map_type::const_pointer a_cpointer = &*const_begin(m);
|
||||
|
||||
The difference compared to ``std::map<Key,T*>`` is that constness
|
||||
is propagated to the pointer (that is, to ``second``).
|
||||
is propagated to the pointer (that is, to ``second``) in ``const_itertor``.
|
||||
|
||||
.. _`modifiers`:
|
||||
|
||||
@@ -183,6 +187,9 @@ Semantics: pointer container requirements
|
||||
|
||||
- Exception safety: Basic guarantee
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -292,11 +292,27 @@ ul.auto-toc {
|
||||
<h2 class="subtitle" id="class-ptr-multiset">Class <tt class="docutils literal"><span class="pre">ptr_multiset</span></tt></h2>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_multiset<T></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">std::multiset<void*></span></tt>
|
||||
to store the pointers.</p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multi_set</span></tt></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="indirect_fun.html">void_ptr_indirect_fun</a></li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
@@ -333,7 +349,7 @@ namespace boost
|
||||
<ul class="simple">
|
||||
<li>Using <tt class="docutils literal"><span class="pre">nullable<T></span></tt> as <tt class="docutils literal"><span class="pre">Key</span></tt> is meaningless and not allowed</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,18 +10,26 @@ Class ``ptr_multiset``
|
||||
A ``ptr_multiset<T>`` is a pointer container that uses an underlying ``std::multiset<void*>``
|
||||
to store the pointers.
|
||||
|
||||
**Hierarchy:**
|
||||
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- ``ptr_multi_set``
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**See also:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_multiset_adapter_
|
||||
- `void_ptr_indirect_fun <indirect_fun.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _associative_ptr_container: associative_ptr_container.html
|
||||
.. _ptr_multiset_adapter: ptr_multiset_adapter.html
|
||||
.. _`indirect predicates`: indirect_fun.html
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
@@ -60,6 +68,9 @@ to store the pointers.
|
||||
|
||||
- Using ``nullable<T>`` as ``Key`` is meaningless and not allowed
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -294,11 +294,24 @@ ul.auto-toc {
|
||||
<p>This class is used to build custom pointer containers with
|
||||
an underlying multiset-like container. The interface of the class is an extension
|
||||
of the interface from <tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multiset</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multiset_adapter</span></tt></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -404,7 +417,7 @@ namespace boost
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -11,15 +11,21 @@ This class is used to build custom pointer containers with
|
||||
an underlying multiset-like container. The interface of the class is an extension
|
||||
of the interface from ``associative_ptr_container``.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_multiset_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _associative_ptr_container: associative_ptr_container.html
|
||||
.. _ptr_multiset: ptr_multiset.html
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- ``ptr_multiset_adapter``
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -126,6 +132,9 @@ Semantics: pointer container requirements
|
||||
|
||||
- Exception safety: Basic guarantee
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -294,15 +294,24 @@ ul.auto-toc {
|
||||
<p>This section describes all the common operations for all the pointer
|
||||
sequences:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a>,</li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a>,</li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a>,</li>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
</ul>
|
||||
<p>The <tt class="docutils literal"><span class="pre">ptr_sequence_adapter</span></tt> is also a concrete class that you can use to create custom pointer
|
||||
containers from.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_sequence_adapter</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_array.html">ptr_array</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -352,14 +361,16 @@ namespace boost
|
||||
iterator erase( const Range& r );
|
||||
|
||||
public: // <a class="reference" href="#pointer-container-requirements">pointer container requirements</a>
|
||||
|
||||
void transfer( iterator before, iterator object,
|
||||
ptr_sequence_adapter& from );
|
||||
void transfer( iterator before, iterator first, iterator last,
|
||||
ptr_sequence_adapter& from );
|
||||
void template< class Range>
|
||||
void transfer( iterator before, const Range& r, ptr_sequence_adapter& from );
|
||||
void transfer( iterator before, ptr_sequence_adapter& from );
|
||||
template< class PtrSequence >
|
||||
void transfer( iterator before, typename PtrSequence::iterator object,
|
||||
PtrSequence& from );
|
||||
template< class PtrSequence >
|
||||
void transfer( iterator before, typename PtrSequence::iterator first, typename PtrSequence::iterator last,
|
||||
PtrSequence& from );
|
||||
void template< class PtrSequence, class Range >
|
||||
void transfer( iterator before, const Range& r, PtrSequence& from );
|
||||
template< class PtrSequence >
|
||||
void transfer( iterator before, PtrSequence& from );
|
||||
|
||||
public: // <a class="reference" href="#algorithms">algorithms</a>
|
||||
|
||||
@@ -608,47 +619,49 @@ Exception safety: Strong guarantee -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="semantics-pointer-container-requirements" name="semantics-pointer-container-requirements"><span id="pointer-container-requirements"></span>Semantics: pointer container requirements</a></h2>
|
||||
<p>You cannot use <tt class="docutils literal"><span class="pre">transfer()</span></tt> to move elements between two
|
||||
different types of containers. This is to avoid
|
||||
problems with different allocators. The requirement might be
|
||||
weakened in the future.</p>
|
||||
<p>You can use <tt class="docutils literal"><span class="pre">transfer()</span></tt> to move elements between two containers of the same type. Furthermore,
|
||||
you can also move elements from a container of type <tt class="docutils literal"><span class="pre">T</span></tt> to a container of type <tt class="docutils literal"><span class="pre">U</span></tt> as long as
|
||||
<tt class="docutils literal"><span class="pre">T::value_type</span></tt> is convertible to <tt class="docutils literal"><span class="pre">U::value_type</span></tt>. An example would be transferring from <tt class="docutils literal"><span class="pre">boost::ptr_vector<Derived></span></tt>
|
||||
to <tt class="docutils literal"><span class="pre">boost::ptr_deque<Base></span></tt>.</p>
|
||||
<p>(<strong>Remark:</strong> <em>When moving elements between two different containers, it is your responsibility to make sure the allocators are compatible.</em>
|
||||
<em>The special latitude of being able to transfer between two different containers is only available for Sequences and not for Associative Containers.</em>)</p>
|
||||
<!-- -->
|
||||
<ul>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">iterator</span> <span class="pre">object,</span> <span class="pre">ptr_sequence_adapter&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">class</span> <span class="pre">PtrSequence</span> <span class="pre">></span> <span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">typename</span> <span class="pre">PtrSequence::iterator</span> <span class="pre">object,</span> <span class="pre">PtrSequence&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li>Requirements: <tt class="docutils literal"><span class="pre">not</span> <span class="pre">from.empty()</span></tt></li>
|
||||
<li>Effects: Inserts the object defined by <tt class="docutils literal"><span class="pre">object</span></tt> into the container and remove it from <tt class="docutils literal"><span class="pre">from</span></tt>.
|
||||
Insertion takes place before <tt class="docutils literal"><span class="pre">before</span></tt>.</li>
|
||||
<li>Postconditions: <tt class="docutils literal"><span class="pre">size()</span></tt> is one more, <tt class="docutils literal"><span class="pre">from.size()</span></tt> is one less.</li>
|
||||
<li>Postconditions: If <tt class="docutils literal"><span class="pre">from.empty()</span></tt>, nothing happens. Otherwise
|
||||
<tt class="docutils literal"><span class="pre">size()</span></tt> is one more, <tt class="docutils literal"><span class="pre">from.size()</span></tt> is one less.</li>
|
||||
<li>Exception safety: Strong guarantee</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</li>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">iterator</span> <span class="pre">first,</span> <span class="pre">iterator</span> <span class="pre">last,</span> <span class="pre">ptr_sequence_adapter&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">class</span> <span class="pre">PtrSequence</span> <span class="pre">></span> <span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">typename</span> <span class="pre">PtrSequence::iterator</span> <span class="pre">first,</span> <span class="pre">typename</span> <span class="pre">PtrSequence::iterator</span> <span class="pre">last,</span> <span class="pre">PtrSequence&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li>Requirements: <tt class="docutils literal"><span class="pre">not</span> <span class="pre">from.empty()</span></tt></li>
|
||||
<li>Requirements: <tt class="docutils literal"><span class="pre">from.size()</span> <span class="pre">>=</span> <span class="pre">std::distance(first,last)</span></tt></li>
|
||||
<li>Effects: Inserts the objects defined by the range <tt class="docutils literal"><span class="pre">[first,last)</span></tt> into the container and remove it from <tt class="docutils literal"><span class="pre">from</span></tt>.
|
||||
Insertion takes place before <tt class="docutils literal"><span class="pre">before</span></tt>.</li>
|
||||
<li>Postconditions: Let <tt class="docutils literal"><span class="pre">N</span> <span class="pre">==</span> <span class="pre">std::distance(first,last);</span></tt> then <tt class="docutils literal"><span class="pre">size()</span></tt> is <tt class="docutils literal"><span class="pre">N</span></tt> more, <tt class="docutils literal"><span class="pre">from.size()</span></tt> is <tt class="docutils literal"><span class="pre">N</span></tt> less.</li>
|
||||
<li>Postconditions: If <tt class="docutils literal"><span class="pre">from.empty()</span></tt>, nothing happens. Otherwise,
|
||||
let <tt class="docutils literal"><span class="pre">N</span> <span class="pre">==</span> <span class="pre">std::distance(first,last);</span></tt> then <tt class="docutils literal"><span class="pre">size()</span></tt> is <tt class="docutils literal"><span class="pre">N</span></tt> more, <tt class="docutils literal"><span class="pre">from.size()</span></tt> is <tt class="docutils literal"><span class="pre">N</span></tt> less.</li>
|
||||
<li>Exception safety: Strong guarantee</li>
|
||||
<li>Complexity: Linear or better</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</li>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">class</span> <span class="pre">Range></span> <span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">const</span> <span class="pre">Range&</span> <span class="pre">r,</span> <span class="pre">ptr_sequence_adapter&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">void</span> <span class="pre">template<</span> <span class="pre">class</span> <span class="pre">PtrSequence,</span> <span class="pre">class</span> <span class="pre">Range</span> <span class="pre">></span> <span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">const</span> <span class="pre">Range&</span> <span class="pre">r,</span> <span class="pre">PtrSequence&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li>Effects: <tt class="docutils literal"><span class="pre">transfer(before,</span> <span class="pre">boost::begin(r),</span> <span class="pre">boost::end(r),</span> <span class="pre">from);</span></tt></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</li>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">ptr_sequence_adapter&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">class</span> <span class="pre">PtrSequence></span> <span class="pre">void</span> <span class="pre">transfer(</span> <span class="pre">iterator</span> <span class="pre">before,</span> <span class="pre">PtrSequence&</span> <span class="pre">from</span> <span class="pre">);</span></tt></p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li>Effects: Transfers all objects from <tt class="docutils literal"><span class="pre">from</span></tt> into the container. Insertion
|
||||
takes place before <tt class="docutils literal"><span class="pre">before</span></tt>.</li>
|
||||
<li>Postconditions: <tt class="docutils literal"><span class="pre">from.empty();</span></tt></li>
|
||||
<li>Exception safety: Strong guarantee</li>
|
||||
<li>Effects: <tt class="docutils literal"><span class="pre">transfer(before,</span> <span class="pre">from,</span> <span class="pre">from);</span></tt></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</li>
|
||||
@@ -722,7 +735,7 @@ ensuring the new sequence is also sorted</li>
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,23 +10,24 @@ Class ``ptr_sequence_adapter``
|
||||
This section describes all the common operations for all the pointer
|
||||
sequences:
|
||||
|
||||
- ptr_vector_,
|
||||
- ptr_list_,
|
||||
- ptr_deque_,
|
||||
|
||||
.. _ptr_vector : ptr_vector.html
|
||||
.. _ptr_list : ptr_list.html
|
||||
.. _ptr_deque : ptr_deque.html
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
|
||||
|
||||
The ``ptr_sequence_adapter`` is also a concrete class that you can use to create custom pointer
|
||||
containers from.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container__
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
__ reversible_ptr_container.html
|
||||
- ``ptr_sequence_adapter``
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -79,14 +80,16 @@ __ reversible_ptr_container.html
|
||||
iterator erase( const Range& r );
|
||||
|
||||
public: // `pointer container requirements`_
|
||||
|
||||
void transfer( iterator before, iterator object,
|
||||
ptr_sequence_adapter& from );
|
||||
void transfer( iterator before, iterator first, iterator last,
|
||||
ptr_sequence_adapter& from );
|
||||
void template< class Range>
|
||||
void transfer( iterator before, const Range& r, ptr_sequence_adapter& from );
|
||||
void transfer( iterator before, ptr_sequence_adapter& from );
|
||||
template< class PtrSequence >
|
||||
void transfer( iterator before, typename PtrSequence::iterator object,
|
||||
PtrSequence& from );
|
||||
template< class PtrSequence >
|
||||
void transfer( iterator before, typename PtrSequence::iterator first, typename PtrSequence::iterator last,
|
||||
PtrSequence& from );
|
||||
void template< class PtrSequence, class Range >
|
||||
void transfer( iterator before, const Range& r, PtrSequence& from );
|
||||
template< class PtrSequence >
|
||||
void transfer( iterator before, PtrSequence& from );
|
||||
|
||||
public: // `algorithms`_
|
||||
|
||||
@@ -330,47 +333,48 @@ Semantics: modifiers
|
||||
Semantics: pointer container requirements
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You cannot use ``transfer()`` to move elements between two
|
||||
different types of containers. This is to avoid
|
||||
problems with different allocators. The requirement might be
|
||||
weakened in the future.
|
||||
You can use ``transfer()`` to move elements between two containers of the same type. Furthermore,
|
||||
you can also move elements from a container of type ``T`` to a container of type ``U`` as long as
|
||||
``T::value_type`` is convertible to ``U::value_type``. An example would be transferring from ``boost::ptr_vector<Derived>``
|
||||
to ``boost::ptr_deque<Base>``.
|
||||
|
||||
(**Remark:** *When moving elements between two different containers, it is your responsibility to make sure the allocators are compatible.*
|
||||
*The special latitude of being able to transfer between two different containers is only available for Sequences and not for Associative Containers.*)
|
||||
|
||||
- ``void transfer( iterator before, iterator object, ptr_sequence_adapter& from );``
|
||||
..
|
||||
|
||||
- Requirements: ``not from.empty()``
|
||||
- ``template< class PtrSequence > void transfer( iterator before, typename PtrSequence::iterator object, PtrSequence& from );``
|
||||
|
||||
- Effects: Inserts the object defined by ``object`` into the container and remove it from ``from``.
|
||||
Insertion takes place before ``before``.
|
||||
|
||||
- Postconditions: ``size()`` is one more, ``from.size()`` is one less.
|
||||
- Postconditions: If ``from.empty()``, nothing happens. Otherwise
|
||||
``size()`` is one more, ``from.size()`` is one less.
|
||||
|
||||
- Exception safety: Strong guarantee
|
||||
|
||||
|
||||
- ``void transfer( iterator before, iterator first, iterator last, ptr_sequence_adapter& from );``
|
||||
- ``template< class PtrSequence > void transfer( iterator before, typename PtrSequence::iterator first, typename PtrSequence::iterator last, PtrSequence& from );``
|
||||
|
||||
- Requirements: ``not from.empty()``
|
||||
- Requirements: ``from.size() >= std::distance(first,last)``
|
||||
|
||||
- Effects: Inserts the objects defined by the range ``[first,last)`` into the container and remove it from ``from``.
|
||||
Insertion takes place before ``before``.
|
||||
|
||||
- Postconditions: Let ``N == std::distance(first,last);`` then ``size()`` is ``N`` more, ``from.size()`` is ``N`` less.
|
||||
- Postconditions: If ``from.empty()``, nothing happens. Otherwise,
|
||||
let ``N == std::distance(first,last);`` then ``size()`` is ``N`` more, ``from.size()`` is ``N`` less.
|
||||
|
||||
- Exception safety: Strong guarantee
|
||||
|
||||
- Complexity: Linear or better
|
||||
|
||||
- ``template< class Range> void transfer( iterator before, const Range& r, ptr_sequence_adapter& from );``
|
||||
- ``void template< class PtrSequence, class Range > void transfer( iterator before, const Range& r, PtrSequence& from );``
|
||||
|
||||
- Effects: ``transfer(before, boost::begin(r), boost::end(r), from);``
|
||||
|
||||
- ``void transfer( iterator before, ptr_sequence_adapter& from );``
|
||||
- ``template< class PtrSequence> void transfer( iterator before, PtrSequence& from );``
|
||||
|
||||
- Effects: Transfers all objects from ``from`` into the container. Insertion
|
||||
takes place before ``before``.
|
||||
|
||||
- Postconditions: ``from.empty();``
|
||||
|
||||
- Exception safety: Strong guarantee
|
||||
- Effects: ``transfer(before, from, from);``
|
||||
|
||||
.. _`algorithms`:
|
||||
|
||||
@@ -420,6 +424,9 @@ contain any nulls*.
|
||||
- Postconditions: (Container versions) ``r.empty()``
|
||||
- Exception safety: nothrow guarantee (the behavior is undefined if the comparison operator throws)
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -292,11 +292,27 @@ ul.auto-toc {
|
||||
<h2 class="subtitle" id="class-ptr-set">Class <tt class="docutils literal"><span class="pre">ptr_set</span></tt></h2>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_set<T></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">std::set<void*></span></tt>
|
||||
to store the pointers.</p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_set</span></tt></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="indirect_fun.html">void_ptr_indirect_fun</a></li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
@@ -334,7 +350,7 @@ namespace boost
|
||||
<ul class="simple">
|
||||
<li>Using <tt class="docutils literal"><span class="pre">nullable<T></span></tt> as <tt class="docutils literal"><span class="pre">Key</span></tt> is meaningless and not allowed</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,17 +10,27 @@ Class ``ptr_set``
|
||||
A ``ptr_set<T>`` is a pointer container that uses an underlying ``std::set<void*>``
|
||||
to store the pointers.
|
||||
|
||||
**Hierarchy:**
|
||||
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- ``ptr_set``
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
|
||||
**See also:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_set_adapter_
|
||||
- `void_ptr_indirect_fun <indirect_fun.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _associative_ptr_container: associative_ptr_container.html
|
||||
.. _ptr_set_adapter: ptr_set_adapter.html
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
@@ -60,6 +70,9 @@ to store the pointers.
|
||||
|
||||
- Using ``nullable<T>`` as ``Key`` is meaningless and not allowed
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -294,11 +294,24 @@ ul.auto-toc {
|
||||
<p>This class is used to build custom pointer containers with
|
||||
an underlying set-like container. The interface of the class is an extension
|
||||
of the interface from <tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_set_adapter</span></tt></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
@@ -404,7 +417,7 @@ An object is only transferred if no equivalent object exists.</li>
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -11,11 +11,21 @@ This class is used to build custom pointer containers with
|
||||
an underlying set-like container. The interface of the class is an extension
|
||||
of the interface from ``associative_ptr_container``.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- associative_ptr_container_
|
||||
- ptr_set_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- ``ptr_set_adapter``
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -124,6 +134,9 @@ Semantics: pointer container requirements
|
||||
|
||||
- Effects: ``return transfer( from.begin(), from.end(), from );``.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -293,12 +293,19 @@ ul.auto-toc {
|
||||
<h1><a id="class-ptr-vector" name="class-ptr-vector">Class <tt class="docutils literal"><span class="pre">ptr_vector</span></tt></a></h1>
|
||||
<p>A <tt class="docutils literal"><span class="pre">ptr_vector<T></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">std::vector<void*></span></tt>
|
||||
to store the pointers.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a></li>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_vector</span></tt></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_array.html">ptr_array</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
@@ -440,7 +447,7 @@ of size least <tt class="docutils literal"><span class="pre">to_reserve</span></
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,15 +10,16 @@ Class ``ptr_vector``
|
||||
A ``ptr_vector<T>`` is a pointer container that uses an underlying ``std::vector<void*>``
|
||||
to store the pointers.
|
||||
|
||||
**See also:**
|
||||
**Hierarchy:**
|
||||
|
||||
- reversible_ptr_container_
|
||||
- ptr_sequence_adapter_
|
||||
- ptr_array_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
.. _reversible_ptr_container: reversible_ptr_container.html
|
||||
.. _ptr_sequence_adapter: ptr_sequence_adapter.html
|
||||
.. _ptr_array: ptr_array.html
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
|
||||
- ``ptr_vector``
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
@@ -154,6 +155,9 @@ Semantics: pointer container requirements
|
||||
|
||||
- Exception safety: Nothrow guarantee
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ ul.auto-toc {
|
||||
<h2 class="subtitle" id="reference">Reference</h2>
|
||||
<p>The documentation is divided into a an explanation for
|
||||
each container. All the common interface is explained only once,
|
||||
but links are always provided to the relevant links.
|
||||
but links are always provided to more relevant information.
|
||||
Please make sure you understand
|
||||
the <a class="reference" href="reference.html#the-clonable-concept">Clonable</a> concept and
|
||||
the <a class="reference" href="reference.html#the-clone-allocator-concept">Clone Allocator</a> concept.</p>
|
||||
@@ -300,36 +300,59 @@ the <a class="reference" href="reference.html#the-clone-allocator-concept">Clone
|
||||
<li><a class="reference" href="conventions.html">Conventions</a></li>
|
||||
<li><a class="reference" href="#the-clonable-concept">The Clonable concept</a></li>
|
||||
<li><a class="reference" href="#the-clone-allocator-concept">The Clone Allocator concept</a></li>
|
||||
<li>Class <a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li>
|
||||
<li>Class <a class="reference" href="associative_ptr_container.html">associative_ptr_container</a></li>
|
||||
<li><a class="reference" href="#pointer-container-adapters">Pointer container adapters</a><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multimap_adapter</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#sequence-containers">Sequence containers</a><ul>
|
||||
<li><a class="reference" href="#class-hierarchy">Class hierarchy</a>:<ul>
|
||||
<li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_array.html">ptr_array</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#associative-containers">Associative containers</a><ul>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multiset</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#serialization">Serialization</a></li>
|
||||
<li><a class="reference" href="indirect_fun.html">Indirected functions</a></li>
|
||||
<li><a class="reference" href="#class-nullable">Class nullable</a></li>
|
||||
<li><a class="reference" href="#exception-classes">Exception classes</a></li>
|
||||
<li><a class="reference" href="#disabling-the-use-of-exceptions">Disabling the use of exceptions</a></li>
|
||||
</ul>
|
||||
<!-- - Class `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
- Class `associative_ptr_container <associative_ptr_container.html>`_
|
||||
- `Pointer container adapters`_
|
||||
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multimap_adapter <ptr_multimap_adapter.html>`_
|
||||
- `Sequence containers`_
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
- `Associative containers`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multiset <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_ -->
|
||||
<div class="section">
|
||||
<h1><a id="the-clonable-concept" name="the-clonable-concept">The Clonable concept</a></h1>
|
||||
<p><strong>Refinement of</strong></p>
|
||||
@@ -543,7 +566,15 @@ namespace boost
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="pointer-container-adapters" name="pointer-container-adapters">Pointer container adapters</a></h1>
|
||||
<h1><a id="class-hierarchy" name="class-hierarchy">Class hierarchy</a></h1>
|
||||
<p>The library consists of the following types of classes:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Pointer container adapters</li>
|
||||
</ol>
|
||||
<!-- -->
|
||||
<ol class="arabic simple" start="2">
|
||||
<li>Pointer containers</li>
|
||||
</ol>
|
||||
<p>The pointer container adapters are used when you
|
||||
want to make a pointer container starting from
|
||||
your own "normal" container. For example, you
|
||||
@@ -552,42 +583,60 @@ in some way; the adapter class then allows you
|
||||
to use your map class as a basis for a new
|
||||
pointer container.</p>
|
||||
<p>The library provides an adapter for each type
|
||||
of standard container:</p>
|
||||
of standard container highlighted as links below:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">reversible_ptr_container</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_vector</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_list</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_deque</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_array</span></tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multimap_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_set</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multi_set</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_map</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multimap</span></tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="pointer-containers" name="pointer-containers">Pointer containers</a></h1>
|
||||
<p>The pointer containers of this library are all built using
|
||||
the <a class="reference" href="#pointer-container-adapters">pointer container adapters</a>. There is a pointer container
|
||||
for each type of "normal" standard container:</p>
|
||||
<div class="section">
|
||||
<h2><a id="sequence-containers" name="sequence-containers">Sequence containers</a></h2>
|
||||
<blockquote>
|
||||
the adapters. There is a pointer container
|
||||
for each type of "normal" standard container highlighted as links below.</p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">reversible_ptr_container</span></tt><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_sequence_adapter</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_array.html">ptr_array</a></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="associative-containers" name="associative-containers">Associative containers</a></h2>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
</li>
|
||||
<li><tt class="docutils literal"><span class="pre">associative_ptr_container</span></tt><ul>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_set_adapter</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multiset_adapter</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_map_adapter</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">ptr_multi_map_adapter</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multiset</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="serialization" name="serialization">Serialization</a></h1>
|
||||
@@ -743,7 +792,7 @@ is also defined.</p>
|
||||
<hr><ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
</ul>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -10,7 +10,7 @@ Reference
|
||||
|
||||
The documentation is divided into a an explanation for
|
||||
each container. All the common interface is explained only once,
|
||||
but links are always provided to the relevant links.
|
||||
but links are always provided to more relevant information.
|
||||
Please make sure you understand
|
||||
the `Clonable <reference.html#the-clonable-concept>`_ concept and
|
||||
the `Clone Allocator <reference.html#the-clone-allocator-concept>`_ concept.
|
||||
@@ -18,27 +18,30 @@ the `Clone Allocator <reference.html#the-clone-allocator-concept>`_ concept.
|
||||
- `Conventions <conventions.html>`_
|
||||
- `The Clonable concept`_
|
||||
- `The Clone Allocator concept`_
|
||||
- Class `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
- Class `associative_ptr_container <associative_ptr_container.html>`_
|
||||
- `Pointer container adapters`_
|
||||
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multimap_adapter <ptr_multimap_adapter.html>`_
|
||||
- `Sequence containers`_
|
||||
- `Class hierarchy`_:
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
- `Associative containers`_
|
||||
- `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multiset <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
- `Serialization`_
|
||||
- `Indirected functions <indirect_fun.html>`_
|
||||
- `Class nullable`_
|
||||
@@ -46,6 +49,29 @@ the `Clone Allocator <reference.html#the-clone-allocator-concept>`_ concept.
|
||||
- `Disabling the use of exceptions`_
|
||||
|
||||
|
||||
..
|
||||
- Class `reversible_ptr_container <reversible_ptr_container.html>`_
|
||||
- Class `associative_ptr_container <associative_ptr_container.html>`_
|
||||
- `Pointer container adapters`_
|
||||
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multimap_adapter <ptr_multimap_adapter.html>`_
|
||||
- `Sequence containers`_
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
- `Associative containers`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multiset <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
|
||||
|
||||
The Clonable concept
|
||||
@@ -217,8 +243,16 @@ container.
|
||||
|
||||
- `Changing the clone allocator <examples.html#changing-the-clone-allocator>`_
|
||||
|
||||
Pointer container adapters
|
||||
++++++++++++++++++++++++++
|
||||
Class hierarchy
|
||||
+++++++++++++++
|
||||
|
||||
The library consists of the following types of classes:
|
||||
|
||||
1. Pointer container adapters
|
||||
|
||||
..
|
||||
|
||||
2. Pointer containers
|
||||
|
||||
The pointer container adapters are used when you
|
||||
want to make a pointer container starting from
|
||||
@@ -229,52 +263,54 @@ to use your map class as a basis for a new
|
||||
pointer container.
|
||||
|
||||
The library provides an adapter for each type
|
||||
of standard container:
|
||||
of standard container highlighted as links below:
|
||||
|
||||
- ptr_sequence_adapter_
|
||||
- ptr_set_adapter_
|
||||
- ptr_multiset_adapter_
|
||||
- ptr_map_adapter_
|
||||
- ptr_multimap_adapter_
|
||||
- ``reversible_ptr_container``
|
||||
|
||||
.. _ptr_sequence_adapter: ptr_sequence_adapter.html
|
||||
.. _ptr_set_adapter: ptr_set_adapter.html
|
||||
.. _ptr_multiset_adapter: ptr_multiset_adapter.html
|
||||
.. _ptr_map_adapter: ptr_map_adapter.html
|
||||
.. _ptr_multimap_adapter: ptr_multimap_adapter.html
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
|
||||
- ``ptr_vector``
|
||||
- ``ptr_list``
|
||||
- ``ptr_deque``
|
||||
- ``ptr_array``
|
||||
|
||||
- ``associative_ptr_container``
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- ``ptr_set``
|
||||
- ``ptr_multi_set``
|
||||
- ``ptr_map``
|
||||
- ``ptr_multimap``
|
||||
|
||||
Pointer containers
|
||||
++++++++++++++++++
|
||||
|
||||
The pointer containers of this library are all built using
|
||||
the `pointer container adapters`_. There is a pointer container
|
||||
for each type of "normal" standard container:
|
||||
the adapters. There is a pointer container
|
||||
for each type of "normal" standard container highlighted as links below.
|
||||
|
||||
Sequence containers
|
||||
-------------------
|
||||
- ``reversible_ptr_container``
|
||||
|
||||
- ptr_vector_
|
||||
- ptr_deque_
|
||||
- ptr_list_
|
||||
- ptr_array_
|
||||
- ``ptr_sequence_adapter``
|
||||
|
||||
Associative containers
|
||||
----------------------
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
|
||||
- ``associative_ptr_container``
|
||||
|
||||
- ``ptr_set_adapter``
|
||||
- ``ptr_multiset_adapter``
|
||||
- ``ptr_map_adapter``
|
||||
- ``ptr_multi_map_adapter``
|
||||
|
||||
- ptr_set_
|
||||
- ptr_multiset_
|
||||
- ptr_map_
|
||||
- ptr_multimap_
|
||||
|
||||
.. _ptr_vector: ptr_vector.html
|
||||
.. _ptr_deque: ptr_deque.html
|
||||
.. _ptr_list: ptr_list.html
|
||||
.. _ptr_array: ptr_array.html
|
||||
.. _ptr_set: ptr_set.html
|
||||
.. _ptr_multiset: ptr_multiset.html
|
||||
.. _ptr_map: ptr_map.html
|
||||
.. _ptr_multimap: ptr_multimap.html
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
Serialization
|
||||
+++++++++++++
|
||||
@@ -449,6 +485,9 @@ is also defined.
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
@@ -293,6 +293,32 @@ ul.auto-toc {
|
||||
<h1><a id="class-reversible-ptr-container" name="class-reversible-ptr-container">Class <tt class="docutils literal"><span class="pre">reversible_ptr_container</span></tt></a></h1>
|
||||
<p>This class is not a real class that can be found in the library.
|
||||
Its purpose is to present the general interface of all the pointer containers.</p>
|
||||
<p><strong>Hierarchy:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">reversible_ptr_container</span></tt><ul>
|
||||
<li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
|
||||
<li><a class="reference" href="ptr_list.html">ptr_list</a></li>
|
||||
<li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
|
||||
<li><a class="reference" href="ptr_array.html">ptr_array</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
|
||||
<li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
|
||||
<li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
|
||||
<li><a class="reference" href="ptr_set.html">ptr_set</a></li>
|
||||
<li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
|
||||
<li><a class="reference" href="ptr_map.html">ptr_map</a></li>
|
||||
<li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong>Navigate:</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
@@ -451,12 +477,13 @@ functionality unless you know what you are doing</em>).</p>
|
||||
<li><tt class="docutils literal"><span class="pre">typedef</span> <span class="pre">...</span> <span class="pre">auto_type</span></tt></li>
|
||||
</ul>
|
||||
<p>This declaration hides a pointer pointer type. You can rely on the following
|
||||
operations:</p>
|
||||
operations</p>
|
||||
<pre class="literal-block">
|
||||
T* operator->() const;
|
||||
T& operator*() const;
|
||||
T* release();
|
||||
~auto_type();
|
||||
operator <em>implementation-defined bool</em>();
|
||||
</pre>
|
||||
<p>The destructor will delete the stored object. It might help to
|
||||
think it is just an <tt class="docutils literal"><span class="pre">std::auto_ptr<T></span></tt>.</p>
|
||||
|
||||
@@ -10,6 +10,29 @@ Class ``reversible_ptr_container``
|
||||
This class is not a real class that can be found in the library.
|
||||
Its purpose is to present the general interface of all the pointer containers.
|
||||
|
||||
**Hierarchy:**
|
||||
|
||||
- ``reversible_ptr_container``
|
||||
|
||||
- `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
|
||||
|
||||
- `ptr_vector <ptr_vector.html>`_
|
||||
- `ptr_list <ptr_list.html>`_
|
||||
- `ptr_deque <ptr_deque.html>`_
|
||||
- `ptr_array <ptr_array.html>`_
|
||||
|
||||
- `associative_ptr_container <associative_ptr_container.html>`_
|
||||
|
||||
- `ptr_set_adapter <ptr_set_adapter.html>`_
|
||||
- `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
|
||||
- `ptr_map_adapter <ptr_map_adapter.html>`_
|
||||
- `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
|
||||
|
||||
- `ptr_set <ptr_set.html>`_
|
||||
- `ptr_multi_set <ptr_multiset.html>`_
|
||||
- `ptr_map <ptr_map.html>`_
|
||||
- `ptr_multimap <ptr_multimap.html>`_
|
||||
|
||||
**Navigate:**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
@@ -172,12 +195,15 @@ functionality unless you know what you are doing*).
|
||||
- ``typedef ... auto_type``
|
||||
|
||||
This declaration hides a pointer pointer type. You can rely on the following
|
||||
operations::
|
||||
operations
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
T* operator->() const;
|
||||
T& operator*() const;
|
||||
T* release();
|
||||
~auto_type();
|
||||
operator *implementation-defined bool*\ ();
|
||||
|
||||
The destructor will delete the stored object. It might help to
|
||||
think it is just an ``std::auto_ptr<T>``.
|
||||
|
||||
23
doc/style.css
Executable file
23
doc/style.css
Executable file
@@ -0,0 +1,23 @@
|
||||
pre{
|
||||
BORDER-RIGHT: gray 1pt solid;
|
||||
PADDING-RIGHT: 2pt;
|
||||
BORDER-TOP: gray 1pt solid;
|
||||
DISPLAY: block;
|
||||
PADDING-LEFT: 2pt;
|
||||
PADDING-BOTTOM: 2pt;
|
||||
BORDER-LEFT: gray 1pt solid;
|
||||
MARGIN-RIGHT: 32pt;
|
||||
PADDING-TOP: 2pt;
|
||||
BORDER-BOTTOM: gray 1pt solid;
|
||||
FONT-FAMILY: "Courier New", Courier, mono;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
|
||||
.keyword{color: #0000FF;}
|
||||
.identifier{}
|
||||
.comment{font-style: italic; color: #008000;}
|
||||
.special{color: #800040;}
|
||||
.preprocessor{color: #3F007F;}
|
||||
.string{font-style: italic; color: #666666;}
|
||||
.literal{font-style: italic; color: #666666;}
|
||||
65
doc/todo.txt
65
doc/todo.txt
@@ -1,21 +1,72 @@
|
||||
1. use splice() to speed up transfer for list
|
||||
|
||||
5. small usage exmaple with each class
|
||||
|
||||
8. use static class hierarchy to ease navigation
|
||||
10. update tutorial to show boost::assign link + auto_ptr
|
||||
|
||||
10. update tutorial to show boost::assign link
|
||||
|
||||
11. should find_key() be added to ptr_map?
|
||||
|
||||
12. add
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
13. transfer for set/map may need to
|
||||
be revisted (rg. !from.empty() precondition)
|
||||
|
||||
to the buttom of each file
|
||||
|
||||
15. Some of the headlines are too big...
|
||||
|
||||
|
||||
18. range-based sort() needs to be provided for list. use stable_sort for this purpose.
|
||||
|
||||
|
||||
19. use flat_set,flat_map internally when certain situations arise, eg. when the size of the objects
|
||||
is small, eg. 4bytes (does this affect key=string?
|
||||
|
||||
|
||||
|
||||
21. map::at() should throw bad_index
|
||||
|
||||
auto_type skal være converter-bar til std::auto_ptr<U>, if the deleter is
|
||||
trivial (heap_clone_allocator)
|
||||
|
||||
(Spørg Thomas Witt om denne ændring can komme med...kan ikke ødelægge existerende kode, som
|
||||
vill have kaldt .release()) Kræve en hel del ambiguity resolution pga auto_ptr augument er
|
||||
templates og ikke non-templates! Desuden kan vi ikke bruge non-template argument, da alle
|
||||
converterings operatorer for auto_ptr tager en & argument og ikke en by-value!!! måske
|
||||
skal der blot et hack til, hvor vi tilføjer en ny ukenkt klasse og overloader kun for
|
||||
den, og så laver en implicit konvertering til denne i static_move_ptr
|
||||
|
||||
The easiert implementation would be to detect its presence in the
|
||||
body of the range based overloads and then dispatch to that implementation.
|
||||
|
||||
|
||||
22. hvor gode er kompilere til at optimere release() for en auto_ptr. Hvordan med move_ptr
|
||||
and auto_ptr interaction? Contracts må kunne fortælle kompileren at den skal
|
||||
genere optimeret kode
|
||||
|
||||
template< class T >
|
||||
class auto_ptr
|
||||
{
|
||||
T* get() const;
|
||||
|
||||
//
|
||||
// this expresses that the constructor is a no-op if
|
||||
// the condition is true. This might be useful in many other
|
||||
// context
|
||||
//
|
||||
~auto_ptr()
|
||||
precondition { if( get() == 0 ) return; }
|
||||
|
||||
T* release()
|
||||
postcondition { get() == 0; }
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
std::auto_ptr<T> p( new T );
|
||||
foo( p.release() );
|
||||
// don't generate destructor
|
||||
|
||||
Does raw_storage iterator have an impact on in-place consrtcution
|
||||
|
||||
|
||||
|
||||
@@ -303,6 +303,7 @@ that you read it all from top to bottom.</p>
|
||||
<li><a class="reference" href="#null-values">Null values</a></li>
|
||||
<li><a class="reference" href="#clonability">Clonability</a></li>
|
||||
<li><a class="reference" href="#new-functions">New functions</a></li>
|
||||
<li><a class="reference" href="#std-auto-ptr-u-overloads">std::auto_ptr<U> overloads</a></li>
|
||||
<li><a class="reference" href="#algorithms">Algorithms</a></li>
|
||||
</ul>
|
||||
<div class="section">
|
||||
@@ -315,8 +316,9 @@ about deleting memory.</p>
|
||||
class animal : <a class="reference" href="http://www.boost.org/libs/utility/utility.htm#Class_noncopyable">boost::noncopyable</a>
|
||||
{
|
||||
public:
|
||||
virtual ~animal() {}
|
||||
virtual void eat() = 0;
|
||||
virtual ~animal() {}
|
||||
virtual void eat() = 0;
|
||||
virtual int age() const = 0;
|
||||
// ...
|
||||
};
|
||||
|
||||
@@ -453,7 +455,23 @@ boost::ptr_map<std::string,animal> animals;
|
||||
animals["bobo"].set_name("bobo");
|
||||
</pre>
|
||||
<p>This requires a default constructor for animals and
|
||||
a function to do the initialization, in this case <tt class="docutils literal"><span class="pre">set_name()</span></tt>;</p>
|
||||
a function to do the initialization, in this case <tt class="docutils literal"><span class="pre">set_name()</span></tt>.</p>
|
||||
<p>A better alternative is to use <a class="reference" href="../../assign/index.html">Boost.Assign</a>
|
||||
to help you out. In particular, consider</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="../../assign/doc/index.html#ptr_push_back">ptr_push_back(), ptr_push_front(), ptr_insert() and ptr_map_insert()</a></li>
|
||||
<li><a class="reference" href="../../assign/doc/index.html#ptr_list_of">ptr_list_of()</a></li>
|
||||
</ul>
|
||||
<p>For example, the above insertion may now be written</p>
|
||||
<pre class="literal-block">
|
||||
boost::ptr_multimap<std::string,animal> animals;
|
||||
|
||||
using namespace boost::assign;
|
||||
ptr_map_insert<monkey>( animals )( "bobo", "bobo" );
|
||||
ptr_map_insert<elephant>( animals )( "bobo", "bobo" );
|
||||
ptr_map_insert<whale>( animals )( "anna", "anna" );
|
||||
ptr_map_insert<emu>( animals )( "anna", "anna" );
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="null-values" name="null-values">Null values</a></h1>
|
||||
@@ -519,7 +537,7 @@ zoo_type zoo, another_zoo;
|
||||
another_zoo.assign( zoo.begin(), zoo.end() );
|
||||
</pre>
|
||||
<p>will fill another zoo with clones of the first zoo. Similarly,
|
||||
insert() can now insert clones into your pointer container</p>
|
||||
<tt class="docutils literal"><span class="pre">insert()</span></tt> can now insert clones into your pointer container</p>
|
||||
<pre class="literal-block">
|
||||
another_zoo.insert( another_zoo.begin(), zoo.begin(), zoo.end() );
|
||||
</pre>
|
||||
@@ -542,7 +560,15 @@ zoo.release(2); // for random access containers
|
||||
<p>You can think of <tt class="docutils literal"><span class="pre">auto_type</span></tt> as a non-copyable form of
|
||||
<tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt>. Notice that when you release an object, the
|
||||
pointer is removed from the container and the containers size
|
||||
shrinks. You can also release the entire container if you
|
||||
shrinks. For containers that store nulls, we can exploit that
|
||||
<tt class="docutils literal"><span class="pre">auto_type</span></tt> is convertible to <tt class="docutils literal"><span class="pre">bool</span></tt>:</p>
|
||||
<pre class="literal-block">
|
||||
if( ptr_vector< nullable<T> >::auto_type r = vec.pop_back() )
|
||||
{
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
<p>You can also release the entire container if you
|
||||
want to return it from a function</p>
|
||||
<pre class="literal-block">
|
||||
std::auto_ptr< boost::ptr_deque<animal> > get_zoo()
|
||||
@@ -570,24 +596,26 @@ as the same as <tt class="docutils literal"><span class="pre">splice()</span></t
|
||||
zoo_type::auto_type old_animal = zoo.replace( zoo.begin(), new monkey("bibi") );
|
||||
zoo.replace( 2, old_animal.release() ); // for random access containers
|
||||
</pre>
|
||||
<p>A map is a little different to iterator over than standard maps.
|
||||
<p>A map is slightly different to iterator over than standard maps.
|
||||
Now we say</p>
|
||||
<pre class="literal-block">
|
||||
typedef boost::ptr_map<std::string, boost::nullable<animal> > animal_map;
|
||||
animal_map map;
|
||||
...
|
||||
for( animal_map::iterator i = map.begin();
|
||||
i != map.end(); ++i )
|
||||
for( animal_map::const_iterator i = map.begin(), e = map.end(); i != e; ++i )
|
||||
{
|
||||
std::cout << "\n key: " << i.key();
|
||||
std::cout << "\n key: " << i->first;
|
||||
std::cout << "\n age: ";
|
||||
|
||||
if( boost::is_null(i) )
|
||||
std::cout << "unknown";
|
||||
else
|
||||
std::cout << i->age();
|
||||
std::cout << i->second->age();
|
||||
}
|
||||
</pre>
|
||||
<p>Except for the check for null, this looks like it would with a normal map. But if <tt class="docutils literal"><span class="pre">age()</span></tt> had
|
||||
not been a <tt class="docutils literal"><span class="pre">const</span></tt> member function,
|
||||
it would not have compiled.</p>
|
||||
<p>Maps can also be indexed with bounds-checking</p>
|
||||
<pre class="literal-block">
|
||||
try
|
||||
@@ -601,6 +629,24 @@ catch( boost::bad_ptr_container_operation& e )
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="std-auto-ptr-u-overloads" name="std-auto-ptr-u-overloads"><tt class="docutils literal"><span class="pre">std::auto_ptr<U></span></tt> overloads</a></h1>
|
||||
<p>Evetime there is a function that takes a <tt class="docutils literal"><span class="pre">T*</span></tt> parameter, there is
|
||||
also a function taking an <tt class="docutils literal"><span class="pre">std::auto_ptr<U></span></tt> parameter. This is of course done
|
||||
to make the library intregrate seamless with <tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt>. For example</p>
|
||||
<pre class="literal-block">
|
||||
std::ptr_vector<Base> vec;
|
||||
vec.push_back( new Base );
|
||||
</pre>
|
||||
<p>is complemented by</p>
|
||||
<pre class="literal-block">
|
||||
std::auto_ptr<Derived> p( new Derived );
|
||||
vec.push_back( p );
|
||||
</pre>
|
||||
<p>Notice that the template argument for <tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt> does not need to
|
||||
follow the template argument for <tt class="docutils literal"><span class="pre">ptr_vector</span></tt> as long as <tt class="docutils literal"><span class="pre">Derived*</span></tt>
|
||||
can be implicitly converted to <tt class="docutils literal"><span class="pre">Base*</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="algorithms" name="algorithms">Algorithms</a></h1>
|
||||
<p>Unfortunately it is not possible to use pointer containers with
|
||||
mutating algorithms from the standard library. However,
|
||||
@@ -631,14 +677,17 @@ zoo.merge( another_zoo );
|
||||
BOOST_ASSERT( another_zoo.empty() );
|
||||
</pre>
|
||||
<p>That is all; now you have learned all the basics!</p>
|
||||
<hr><p><strong>See also</strong></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="guidelines.html">Usage guidelines</a></li>
|
||||
<li><a class="reference" href="../../conversion/cast.htm#Polymorphic_castl">Cast utilities</a></li>
|
||||
</ul>
|
||||
<p><strong>Navigate</strong></p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="ptr_container.html">home</a></li>
|
||||
<li><a class="reference" href="examples.html">examples</a></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<hr><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
|
||||
@@ -21,6 +21,7 @@ that you read it all from top to bottom.
|
||||
* `Null values`_
|
||||
* `Clonability`_
|
||||
* `New functions`_
|
||||
* `std::auto_ptr<U> overloads`_
|
||||
* `Algorithms`_
|
||||
|
||||
Basic usage
|
||||
@@ -37,8 +38,9 @@ Let us assume that we have an OO-hierarchy of animals
|
||||
class animal : `boost::noncopyable <http://www.boost.org/libs/utility/utility.htm#Class_noncopyable>`_
|
||||
{
|
||||
public:
|
||||
virtual ~animal() {}
|
||||
virtual void eat() = 0;
|
||||
virtual ~animal() {}
|
||||
virtual void eat() = 0;
|
||||
virtual int age() const = 0;
|
||||
// ...
|
||||
};
|
||||
|
||||
@@ -181,7 +183,25 @@ to avoid the clumsiness::
|
||||
animals["bobo"].set_name("bobo");
|
||||
|
||||
This requires a default constructor for animals and
|
||||
a function to do the initialization, in this case ``set_name()``;
|
||||
a function to do the initialization, in this case ``set_name()``.
|
||||
|
||||
A better alternative is to use `Boost.Assign <../../assign/index.html>`_
|
||||
to help you out. In particular, consider
|
||||
|
||||
- `ptr_push_back(), ptr_push_front(), ptr_insert() and ptr_map_insert() <../../assign/doc/index.html#ptr_push_back>`_
|
||||
|
||||
- `ptr_list_of() <../../assign/doc/index.html#ptr_list_of>`_
|
||||
|
||||
For example, the above insertion may now be written ::
|
||||
|
||||
boost::ptr_multimap<std::string,animal> animals;
|
||||
|
||||
using namespace boost::assign;
|
||||
ptr_map_insert<monkey>( animals )( "bobo", "bobo" );
|
||||
ptr_map_insert<elephant>( animals )( "bobo", "bobo" );
|
||||
ptr_map_insert<whale>( animals )( "anna", "anna" );
|
||||
ptr_map_insert<emu>( animals )( "anna", "anna" );
|
||||
|
||||
|
||||
Null values
|
||||
-----------
|
||||
@@ -249,7 +269,7 @@ can exploit the clonability of the animal objects. For example ::
|
||||
another_zoo.assign( zoo.begin(), zoo.end() );
|
||||
|
||||
will fill another zoo with clones of the first zoo. Similarly,
|
||||
insert() can now insert clones into your pointer container ::
|
||||
``insert()`` can now insert clones into your pointer container ::
|
||||
|
||||
another_zoo.insert( another_zoo.begin(), zoo.begin(), zoo.end() );
|
||||
|
||||
@@ -273,7 +293,15 @@ animal from the zoo ::
|
||||
You can think of ``auto_type`` as a non-copyable form of
|
||||
``std::auto_ptr``. Notice that when you release an object, the
|
||||
pointer is removed from the container and the containers size
|
||||
shrinks. You can also release the entire container if you
|
||||
shrinks. For containers that store nulls, we can exploit that
|
||||
``auto_type`` is convertible to ``bool``::
|
||||
|
||||
if( ptr_vector< nullable<T> >::auto_type r = vec.pop_back() )
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
You can also release the entire container if you
|
||||
want to return it from a function ::
|
||||
|
||||
std::auto_ptr< boost::ptr_deque<animal> > get_zoo()
|
||||
@@ -302,23 +330,26 @@ If you want to replace an element, you can easily do so ::
|
||||
zoo_type::auto_type old_animal = zoo.replace( zoo.begin(), new monkey("bibi") );
|
||||
zoo.replace( 2, old_animal.release() ); // for random access containers
|
||||
|
||||
A map is a little different to iterator over than standard maps.
|
||||
A map is slightly different to iterator over than standard maps.
|
||||
Now we say ::
|
||||
|
||||
typedef boost::ptr_map<std::string, boost::nullable<animal> > animal_map;
|
||||
animal_map map;
|
||||
...
|
||||
for( animal_map::iterator i = map.begin();
|
||||
i != map.end(); ++i )
|
||||
for( animal_map::const_iterator i = map.begin(), e = map.end(); i != e; ++i )
|
||||
{
|
||||
std::cout << "\n key: " << i.key();
|
||||
std::cout << "\n key: " << i->first;
|
||||
std::cout << "\n age: ";
|
||||
|
||||
if( boost::is_null(i) )
|
||||
std::cout << "unknown";
|
||||
else
|
||||
std::cout << i->age();
|
||||
std::cout << i->second->age();
|
||||
}
|
||||
|
||||
Except for the check for null, this looks like it would with a normal map. But if ``age()`` had
|
||||
not been a ``const`` member function,
|
||||
it would not have compiled.
|
||||
|
||||
Maps can also be indexed with bounds-checking ::
|
||||
|
||||
@@ -331,6 +362,25 @@ Maps can also be indexed with bounds-checking ::
|
||||
// "bobo" not found
|
||||
}
|
||||
|
||||
``std::auto_ptr<U>`` overloads
|
||||
------------------------------
|
||||
|
||||
Evetime there is a function that takes a ``T*`` parameter, there is
|
||||
also a function taking an ``std::auto_ptr<U>`` parameter. This is of course done
|
||||
to make the library intregrate seamless with ``std::auto_ptr``. For example ::
|
||||
|
||||
std::ptr_vector<Base> vec;
|
||||
vec.push_back( new Base );
|
||||
|
||||
is complemented by ::
|
||||
|
||||
std::auto_ptr<Derived> p( new Derived );
|
||||
vec.push_back( p );
|
||||
|
||||
Notice that the template argument for ``std::auto_ptr`` does not need to
|
||||
follow the template argument for ``ptr_vector`` as long as ``Derived*``
|
||||
can be implicitly converted to ``Base*``.
|
||||
|
||||
Algorithms
|
||||
----------
|
||||
|
||||
@@ -367,11 +417,24 @@ Finally you may want to merge together two sorted containers::
|
||||
|
||||
That is all; now you have learned all the basics!
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
**See also**
|
||||
|
||||
- `Usage guidelines <guidelines.html>`_
|
||||
|
||||
- `Cast utilities <../../conversion/cast.htm#Polymorphic_castl>`_
|
||||
|
||||
**Navigate**
|
||||
|
||||
- `home <ptr_container.html>`_
|
||||
- `examples <examples.html>`_
|
||||
- `home <ptr_container.html>`_
|
||||
- `examples <examples.html>`_
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<hr>
|
||||
|
||||
:Copyright: Thorsten Ottosen 2004-2006.
|
||||
|
||||
|
||||
365
doc/tutorial_example.html
Executable file
365
doc/tutorial_example.html
Executable file
@@ -0,0 +1,365 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title> </title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<pre><span class=comment>//
|
||||
// Boost.Pointer Container
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/ptr_container/
|
||||
//
|
||||
|
||||
//
|
||||
// This example is intended to get you started.
|
||||
// Notice how the smart container
|
||||
//
|
||||
// 1. takes ownership of objects
|
||||
// 2. transfers ownership
|
||||
// 3. applies indirection to iterators
|
||||
// 4. clones objects from other smart containers
|
||||
//
|
||||
|
||||
//
|
||||
// First we select which container to use.
|
||||
//</span>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>ptr_container</span><span class=special>/</span><span class=identifier>ptr_deque</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
||||
|
||||
<span class=comment>//
|
||||
// we need these later in the example
|
||||
//</span>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>assert</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>string</span><span class=special>></span>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>exception</span><span class=special>></span>
|
||||
|
||||
|
||||
<span class=comment>//
|
||||
// Then we define a small polymorphic class
|
||||
// hierarchy.
|
||||
//</span>
|
||||
|
||||
<span class=keyword>class</span> <span class=identifier>animal</span> <span class=special>:</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>noncopyable</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>virtual</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>do_speak</span><span class=special>()</span> <span class=keyword>const</span> <span class=special>=</span> <span class=number>0</span><span class=special>;</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>name_</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>protected</span><span class=special>:</span>
|
||||
<span class=comment>//
|
||||
// Animals cannot be copied...
|
||||
//</span>
|
||||
<span class=identifier>animal</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>animal</span><span class=special>&</span> <span class=identifier>r</span> <span class=special>)</span> <span class=special>:</span> <span class=identifier>name_</span><span class=special>(</span> <span class=identifier>r</span><span class=special>.</span><span class=identifier>name_</span> <span class=special>)</span> <span class=special>{</span> <span class=special>}</span>
|
||||
<span class=keyword>void</span> <span class=keyword>operator</span><span class=special>=(</span> <span class=keyword>const</span> <span class=identifier>animal</span><span class=special>&</span> <span class=special>);</span>
|
||||
|
||||
<span class=keyword>private</span><span class=special>:</span>
|
||||
<span class=comment>//
|
||||
// ...but due to advances in genetics, we can clone them!
|
||||
//</span>
|
||||
|
||||
<span class=keyword>virtual</span> <span class=identifier>animal</span><span class=special>*</span> <span class=identifier>do_clone</span><span class=special>()</span> <span class=keyword>const</span> <span class=special>=</span> <span class=number>0</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>public</span><span class=special>:</span>
|
||||
<span class=identifier>animal</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&</span> <span class=identifier>name</span> <span class=special>)</span> <span class=special>:</span> <span class=identifier>name_</span><span class=special>(</span><span class=identifier>name</span><span class=special>)</span> <span class=special>{</span> <span class=special>}</span>
|
||||
<span class=keyword>virtual</span> <span class=special>~</span><span class=identifier>animal</span><span class=special>()</span> <span class=keyword>throw</span><span class=special>()</span> <span class=special>{</span> <span class=special>}</span>
|
||||
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>speak</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>do_speak</span><span class=special>();</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>name</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>name_</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=identifier>animal</span><span class=special>*</span> <span class=identifier>clone</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>do_clone</span><span class=special>();</span>
|
||||
<span class=special>}</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=comment>//
|
||||
// An animal is still not Clonable. We need this last hook.
|
||||
//
|
||||
// Notice that we pass the animal by const reference
|
||||
// and return by pointer.
|
||||
//</span>
|
||||
|
||||
<span class=identifier>animal</span><span class=special>*</span> <span class=identifier>new_clone</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>animal</span><span class=special>&</span> <span class=identifier>a</span> <span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>a</span><span class=special>.</span><span class=identifier>clone</span><span class=special>();</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// We do not need to define 'delete_clone()' since
|
||||
// since the default is to call the default 'operator delete()'.
|
||||
//</span>
|
||||
|
||||
<span class=keyword>const</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>muuuh</span> <span class=special>=</span> <span class=string>"Muuuh!"</span><span class=special>;</span>
|
||||
<span class=keyword>const</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>oiink</span> <span class=special>=</span> <span class=string>"Oiiink"</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>class</span> <span class=identifier>cow</span> <span class=special>:</span> <span class=keyword>public</span> <span class=identifier>animal</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>virtual</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>do_speak</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>muuuh</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>virtual</span> <span class=identifier>animal</span><span class=special>*</span> <span class=identifier>do_clone</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=keyword>new</span> <span class=identifier>cow</span><span class=special>(</span> <span class=special>*</span><span class=keyword>this</span> <span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>public</span><span class=special>:</span>
|
||||
<span class=identifier>cow</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&</span> <span class=identifier>name</span> <span class=special>)</span> <span class=special>:</span> <span class=identifier>animal</span><span class=special>(</span><span class=identifier>name</span><span class=special>)</span> <span class=special>{</span> <span class=special>}</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=keyword>class</span> <span class=identifier>pig</span> <span class=special>:</span> <span class=keyword>public</span> <span class=identifier>animal</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>virtual</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>do_speak</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>oiink</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>virtual</span> <span class=identifier>animal</span><span class=special>*</span> <span class=identifier>do_clone</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=keyword>new</span> <span class=identifier>pig</span><span class=special>(</span> <span class=special>*</span><span class=keyword>this</span> <span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>public</span><span class=special>:</span>
|
||||
<span class=identifier>pig</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&</span> <span class=identifier>name</span> <span class=special>)</span> <span class=special>:</span> <span class=identifier>animal</span><span class=special>(</span><span class=identifier>name</span><span class=special>)</span> <span class=special>{</span> <span class=special>}</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Then we, of course, need a place to put all
|
||||
// those animals.
|
||||
//</span>
|
||||
|
||||
<span class=keyword>class</span> <span class=identifier>farm</span>
|
||||
<span class=special>{</span>
|
||||
<span class=comment>//
|
||||
// This is where the smart containers are handy
|
||||
//</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>ptr_deque</span><span class=special><</span><span class=identifier>animal</span><span class=special>></span> <span class=identifier>barn_type</span><span class=special>;</span>
|
||||
<span class=identifier>barn_type</span> <span class=identifier>barn</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>//
|
||||
// An error type
|
||||
//</span>
|
||||
<span class=keyword>struct</span> <span class=identifier>farm_trouble</span> <span class=special>:</span> <span class=keyword>public</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>exception</span> <span class=special>{</span> <span class=special>};</span>
|
||||
|
||||
<span class=keyword>public</span><span class=special>:</span>
|
||||
<span class=comment>//
|
||||
// We would like to make it possible to
|
||||
// iterate over the animals in the farm
|
||||
//</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>barn_type</span><span class=special>::</span><span class=identifier>iterator</span> <span class=identifier>animal_iterator</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>//
|
||||
// We also need to count the farm's size...
|
||||
//</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>barn_type</span><span class=special>::</span><span class=identifier>size_type</span> <span class=identifier>size_type</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>//
|
||||
// And we also want to transfer an animal
|
||||
// safely around. The easiest way to think
|
||||
// about '::auto_type' is to imagine a simplified
|
||||
// 'std::auto_ptr<T>' ... this means you can expect
|
||||
//
|
||||
// T* operator->()
|
||||
// T* release()
|
||||
// deleting destructor
|
||||
//
|
||||
// but not more.
|
||||
//</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>barn_type</span><span class=special>::</span><span class=identifier>auto_type</span> <span class=identifier>animal_transport</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Create an empty farm.
|
||||
//</span>
|
||||
<span class=identifier>farm</span><span class=special>()</span> <span class=special>{</span> <span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// We need a constructor that can make a new
|
||||
// farm by cloning a range of animals.
|
||||
//</span>
|
||||
<span class=identifier>farm</span><span class=special>(</span> <span class=identifier>animal_iterator</span> <span class=identifier>begin</span><span class=special>,</span> <span class=identifier>animal_iterator</span> <span class=identifier>end</span> <span class=special>)</span>
|
||||
<span class=special>:</span>
|
||||
<span class=comment>//
|
||||
// Objects are always cloned before insertion
|
||||
// unless we explicitly add a pointer or
|
||||
// use 'release()'. Therefore we actually
|
||||
// clone all animals in the range
|
||||
//</span>
|
||||
<span class=identifier>barn</span><span class=special>(</span> <span class=identifier>begin</span><span class=special>,</span> <span class=identifier>end</span> <span class=special>)</span> <span class=special>{</span> <span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// ... so we need some other function too
|
||||
//</span>
|
||||
|
||||
<span class=identifier>animal_iterator</span> <span class=identifier>begin</span><span class=special>()</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>barn</span><span class=special>.</span><span class=identifier>begin</span><span class=special>();</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=identifier>animal_iterator</span> <span class=identifier>end</span><span class=special>()</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>barn</span><span class=special>.</span><span class=identifier>end</span><span class=special>();</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Here it is quite ok to have an 'animal*' argument.
|
||||
// The smart container will handle all ownership
|
||||
// issues.
|
||||
//</span>
|
||||
<span class=keyword>void</span> <span class=identifier>buy_animal</span><span class=special>(</span> <span class=identifier>animal</span><span class=special>*</span> <span class=identifier>a</span> <span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=identifier>barn</span><span class=special>.</span><span class=identifier>push_back</span><span class=special>(</span> <span class=identifier>a</span> <span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// The farm can also be in economical trouble and
|
||||
// therefore be in the need to sell animals.
|
||||
//</span>
|
||||
<span class=identifier>animal_transport</span> <span class=identifier>sell_animal</span><span class=special>(</span> <span class=identifier>animal_iterator</span> <span class=identifier>to_sell</span> <span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>if</span><span class=special>(</span> <span class=identifier>to_sell</span> <span class=special>==</span> <span class=identifier>end</span><span class=special>()</span> <span class=special>)</span>
|
||||
<span class=keyword>throw</span> <span class=identifier>farm_trouble</span><span class=special>();</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Here we remove the animal from the barn,
|
||||
// but the animal is not deleted yet...it's
|
||||
// up to the buyer to decide what
|
||||
// to do with it.
|
||||
//</span>
|
||||
<span class=keyword>return</span> <span class=identifier>barn</span><span class=special>.</span><span class=identifier>release</span><span class=special>(</span> <span class=identifier>to_sell</span> <span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// How big a farm do we have?
|
||||
//</span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>size</span><span class=special>()</span> <span class=keyword>const</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>barn</span><span class=special>.</span><span class=identifier>size</span><span class=special>();</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// If things are bad, we might choose to sell all animals :-(
|
||||
//</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>auto_ptr</span><span class=special><</span><span class=identifier>barn_type</span><span class=special>></span> <span class=identifier>sell_farm</span><span class=special>()</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>barn</span><span class=special>.</span><span class=identifier>release</span><span class=special>();</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=comment>//
|
||||
// However, if things are good, we might buy somebody
|
||||
// else's farm :-)
|
||||
//</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>buy_farm</span><span class=special>(</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>auto_ptr</span><span class=special><</span><span class=identifier>barn_type</span><span class=special>></span> <span class=identifier>other</span> <span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=comment>//
|
||||
// This line inserts all the animals from 'other'
|
||||
// and is guaranteed either to succeed or to have no
|
||||
// effect
|
||||
//</span>
|
||||
<span class=identifier>barn</span><span class=special>.</span><span class=identifier>transfer</span><span class=special>(</span> <span class=identifier>barn</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span> <span class=comment>// insert new animals at the end</span>
|
||||
<span class=special>*</span><span class=identifier>other</span> <span class=special>);</span> <span class=comment>// we want to transfer all animals,
|
||||
// so we use the whole container as argument
|
||||
//
|
||||
// You might think you would have to do
|
||||
//
|
||||
// other.release();
|
||||
//
|
||||
// but '*other' is empty and can go out of scope as it wants
|
||||
//</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>other</span><span class=special>-></span><span class=identifier>empty</span><span class=special>()</span> <span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=special>};</span> <span class=comment>// class 'farm'.</span>
|
||||
|
||||
<span class=keyword>int</span> <span class=identifier>main</span><span class=special>()</span>
|
||||
<span class=special>{</span>
|
||||
<span class=comment>//
|
||||
// First we make a farm
|
||||
//</span>
|
||||
<span class=identifier>farm</span> <span class=identifier>animal_farm</span><span class=special>;</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>0u</span> <span class=special>);</span>
|
||||
|
||||
<span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>buy_animal</span><span class=special>(</span> <span class=keyword>new</span> <span class=identifier>pig</span><span class=special>(</span><span class=string>"Betty"</span><span class=special>)</span> <span class=special>);</span>
|
||||
<span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>buy_animal</span><span class=special>(</span> <span class=keyword>new</span> <span class=identifier>pig</span><span class=special>(</span><span class=string>"Benny"</span><span class=special>)</span> <span class=special>);</span>
|
||||
<span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>buy_animal</span><span class=special>(</span> <span class=keyword>new</span> <span class=identifier>pig</span><span class=special>(</span><span class=string>"Jeltzin"</span><span class=special>)</span> <span class=special>);</span>
|
||||
<span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>buy_animal</span><span class=special>(</span> <span class=keyword>new</span> <span class=identifier>cow</span><span class=special>(</span><span class=string>"Hanz"</span><span class=special>)</span> <span class=special>);</span>
|
||||
<span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>buy_animal</span><span class=special>(</span> <span class=keyword>new</span> <span class=identifier>cow</span><span class=special>(</span><span class=string>"Mary"</span><span class=special>)</span> <span class=special>);</span>
|
||||
<span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>buy_animal</span><span class=special>(</span> <span class=keyword>new</span> <span class=identifier>cow</span><span class=special>(</span><span class=string>"Frederik"</span><span class=special>)</span> <span class=special>);</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>6u</span> <span class=special>);</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Then we make another farm...it will actually contain
|
||||
// a clone of the other farm.
|
||||
//</span>
|
||||
<span class=identifier>farm</span> <span class=identifier>new_farm</span><span class=special>(</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>end</span><span class=special>()</span> <span class=special>);</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>new_farm</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>6u</span> <span class=special>);</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Is it really clones in the new farm?
|
||||
//</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>new_farm</span><span class=special>.</span><span class=identifier>begin</span><span class=special>()-></span><span class=identifier>name</span><span class=special>()</span> <span class=special>==</span> <span class=string>"Betty"</span> <span class=special>);</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Then we search for an animal, Mary (the Crown Princess of Denmark),
|
||||
// because we would like to buy her ...
|
||||
//</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>farm</span><span class=special>::</span><span class=identifier>animal_iterator</span> <span class=identifier>iterator</span><span class=special>;</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>to_sell</span><span class=special>;</span>
|
||||
<span class=keyword>for</span><span class=special>(</span> <span class=identifier>iterator</span> <span class=identifier>i</span> <span class=special>=</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span>
|
||||
<span class=identifier>end</span> <span class=special>=</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>end</span><span class=special>();</span>
|
||||
<span class=identifier>i</span> <span class=special>!=</span> <span class=identifier>end</span><span class=special>;</span> <span class=special>++</span><span class=identifier>i</span> <span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>if</span><span class=special>(</span> <span class=identifier>i</span><span class=special>-></span><span class=identifier>name</span><span class=special>()</span> <span class=special>==</span> <span class=string>"Mary"</span> <span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=identifier>to_sell</span> <span class=special>=</span> <span class=identifier>i</span><span class=special>;</span>
|
||||
<span class=keyword>break</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=identifier>farm</span><span class=special>::</span><span class=identifier>animal_transport</span> <span class=identifier>mary</span> <span class=special>=</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>sell_animal</span><span class=special>(</span> <span class=identifier>to_sell</span> <span class=special>);</span>
|
||||
|
||||
|
||||
<span class=keyword>if</span><span class=special>(</span> <span class=identifier>mary</span><span class=special>-></span><span class=identifier>speak</span><span class=special>()</span> <span class=special>==</span> <span class=identifier>muuuh</span> <span class=special>)</span>
|
||||
<span class=comment>//
|
||||
// Great, Mary is a cow, and she may live longer
|
||||
//</span>
|
||||
<span class=identifier>new_farm</span><span class=special>.</span><span class=identifier>buy_animal</span><span class=special>(</span> <span class=identifier>mary</span><span class=special>.</span><span class=identifier>release</span><span class=special>()</span> <span class=special>);</span>
|
||||
<span class=keyword>else</span>
|
||||
<span class=comment>//
|
||||
// Then the animal would be destroyed (!)
|
||||
// when we go out of scope.
|
||||
//</span>
|
||||
<span class=special>;</span>
|
||||
|
||||
<span class=comment>//
|
||||
// Now we can observe some changes to the two farms...
|
||||
//</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>5u</span> <span class=special>);</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>new_farm</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>7u</span> <span class=special>);</span>
|
||||
|
||||
<span class=comment>//
|
||||
// The new farm has however underestimated how much
|
||||
// it cost to feed Mary and its owner is forced to sell the farm...
|
||||
//</span>
|
||||
<span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>buy_farm</span><span class=special>(</span> <span class=identifier>new_farm</span><span class=special>.</span><span class=identifier>sell_farm</span><span class=special>()</span> <span class=special>);</span>
|
||||
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>new_farm</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>0u</span> <span class=special>);</span>
|
||||
<span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>animal_farm</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>12u</span> <span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user