750 lines
30 KiB
HTML
750 lines
30 KiB
HTML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
|
|
<title>Boost Pointer Container Library</title>
|
|
<meta name="authors" content="Thorsten Ottosen" />
|
|
<meta name="date" content="27th of October 2007" />
|
|
<meta name="copyright" content="Thorsten Ottosen 2004-2007. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt)." />
|
|
<style type="text/css">
|
|
|
|
/*
|
|
:Author: David Goodger (goodger@python.org)
|
|
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
|
:Copyright: This stylesheet has been placed in the public domain.
|
|
|
|
Default cascading style sheet for the HTML output of Docutils.
|
|
|
|
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
|
customize this style sheet.
|
|
*/
|
|
|
|
/* used to remove borders from tables and images */
|
|
.borderless, table.borderless td, table.borderless th {
|
|
border: 0 }
|
|
|
|
table.borderless td, table.borderless th {
|
|
/* Override padding for "table.docutils td" with "! important".
|
|
The right padding separates the table cells. */
|
|
padding: 0 0.5em 0 0 ! important }
|
|
|
|
.first {
|
|
/* Override more specific margin styles with "! important". */
|
|
margin-top: 0 ! important }
|
|
|
|
.last, .with-subtitle {
|
|
margin-bottom: 0 ! important }
|
|
|
|
.hidden {
|
|
display: none }
|
|
|
|
.subscript {
|
|
vertical-align: sub;
|
|
font-size: smaller }
|
|
|
|
.superscript {
|
|
vertical-align: super;
|
|
font-size: smaller }
|
|
|
|
a.toc-backref {
|
|
text-decoration: none ;
|
|
color: black }
|
|
|
|
blockquote.epigraph {
|
|
margin: 2em 5em ; }
|
|
|
|
dl.docutils dd {
|
|
margin-bottom: 0.5em }
|
|
|
|
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
|
dl.docutils dt {
|
|
font-weight: bold }
|
|
*/
|
|
|
|
div.abstract {
|
|
margin: 2em 5em }
|
|
|
|
div.abstract p.topic-title {
|
|
font-weight: bold ;
|
|
text-align: center }
|
|
|
|
div.admonition, div.attention, div.caution, div.danger, div.error,
|
|
div.hint, div.important, div.note, div.tip, div.warning {
|
|
margin: 2em ;
|
|
border: medium outset ;
|
|
padding: 1em }
|
|
|
|
div.admonition p.admonition-title, div.hint p.admonition-title,
|
|
div.important p.admonition-title, div.note p.admonition-title,
|
|
div.tip p.admonition-title {
|
|
font-weight: bold ;
|
|
font-family: sans-serif }
|
|
|
|
div.attention p.admonition-title, div.caution p.admonition-title,
|
|
div.danger p.admonition-title, div.error p.admonition-title,
|
|
div.warning p.admonition-title, .code .error {
|
|
color: red ;
|
|
font-weight: bold ;
|
|
font-family: sans-serif }
|
|
|
|
/* Uncomment (and remove this text!) to get reduced vertical space in
|
|
compound paragraphs.
|
|
div.compound .compound-first, div.compound .compound-middle {
|
|
margin-bottom: 0.5em }
|
|
|
|
div.compound .compound-last, div.compound .compound-middle {
|
|
margin-top: 0.5em }
|
|
*/
|
|
|
|
div.dedication {
|
|
margin: 2em 5em ;
|
|
text-align: center ;
|
|
font-style: italic }
|
|
|
|
div.dedication p.topic-title {
|
|
font-weight: bold ;
|
|
font-style: normal }
|
|
|
|
div.figure {
|
|
margin-left: 2em ;
|
|
margin-right: 2em }
|
|
|
|
div.footer, div.header {
|
|
clear: both;
|
|
font-size: smaller }
|
|
|
|
div.line-block {
|
|
display: block ;
|
|
margin-top: 1em ;
|
|
margin-bottom: 1em }
|
|
|
|
div.line-block div.line-block {
|
|
margin-top: 0 ;
|
|
margin-bottom: 0 ;
|
|
margin-left: 1.5em }
|
|
|
|
div.sidebar {
|
|
margin: 0 0 0.5em 1em ;
|
|
border: medium outset ;
|
|
padding: 1em ;
|
|
background-color: #ffffee ;
|
|
width: 40% ;
|
|
float: right ;
|
|
clear: right }
|
|
|
|
div.sidebar p.rubric {
|
|
font-family: sans-serif ;
|
|
font-size: medium }
|
|
|
|
div.system-messages {
|
|
margin: 5em }
|
|
|
|
div.system-messages h1 {
|
|
color: red }
|
|
|
|
div.system-message {
|
|
border: medium outset ;
|
|
padding: 1em }
|
|
|
|
div.system-message p.system-message-title {
|
|
color: red ;
|
|
font-weight: bold }
|
|
|
|
div.topic {
|
|
margin: 2em }
|
|
|
|
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
|
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
|
margin-top: 0.4em }
|
|
|
|
h1.title {
|
|
text-align: center }
|
|
|
|
h2.subtitle {
|
|
text-align: center }
|
|
|
|
hr.docutils {
|
|
width: 75% }
|
|
|
|
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
|
clear: left ;
|
|
float: left ;
|
|
margin-right: 1em }
|
|
|
|
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
|
clear: right ;
|
|
float: right ;
|
|
margin-left: 1em }
|
|
|
|
img.align-center, .figure.align-center, object.align-center {
|
|
display: block;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
|
|
table.align-center {
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
|
|
.align-left {
|
|
text-align: left }
|
|
|
|
.align-center {
|
|
clear: both ;
|
|
text-align: center }
|
|
|
|
.align-right {
|
|
text-align: right }
|
|
|
|
/* reset inner alignment in figures */
|
|
div.align-right {
|
|
text-align: inherit }
|
|
|
|
/* div.align-center * { */
|
|
/* text-align: left } */
|
|
|
|
.align-top {
|
|
vertical-align: top }
|
|
|
|
.align-middle {
|
|
vertical-align: middle }
|
|
|
|
.align-bottom {
|
|
vertical-align: bottom }
|
|
|
|
ol.simple, ul.simple {
|
|
margin-bottom: 1em }
|
|
|
|
ol.arabic {
|
|
list-style: decimal }
|
|
|
|
ol.loweralpha {
|
|
list-style: lower-alpha }
|
|
|
|
ol.upperalpha {
|
|
list-style: upper-alpha }
|
|
|
|
ol.lowerroman {
|
|
list-style: lower-roman }
|
|
|
|
ol.upperroman {
|
|
list-style: upper-roman }
|
|
|
|
p.attribution {
|
|
text-align: right ;
|
|
margin-left: 50% }
|
|
|
|
p.caption {
|
|
font-style: italic }
|
|
|
|
p.credits {
|
|
font-style: italic ;
|
|
font-size: smaller }
|
|
|
|
p.label {
|
|
white-space: nowrap }
|
|
|
|
p.rubric {
|
|
font-weight: bold ;
|
|
font-size: larger ;
|
|
color: maroon ;
|
|
text-align: center }
|
|
|
|
p.sidebar-title {
|
|
font-family: sans-serif ;
|
|
font-weight: bold ;
|
|
font-size: larger }
|
|
|
|
p.sidebar-subtitle {
|
|
font-family: sans-serif ;
|
|
font-weight: bold }
|
|
|
|
p.topic-title {
|
|
font-weight: bold }
|
|
|
|
pre.address {
|
|
margin-bottom: 0 ;
|
|
margin-top: 0 ;
|
|
font: inherit }
|
|
|
|
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
|
margin-left: 2em ;
|
|
margin-right: 2em }
|
|
|
|
pre.code .ln { color: grey; } /* line numbers */
|
|
pre.code, code { background-color: #eeeeee }
|
|
pre.code .comment, code .comment { color: #5C6576 }
|
|
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
|
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
|
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
|
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
|
pre.code .inserted, code .inserted { background-color: #A3D289}
|
|
|
|
span.classifier {
|
|
font-family: sans-serif ;
|
|
font-style: oblique }
|
|
|
|
span.classifier-delimiter {
|
|
font-family: sans-serif ;
|
|
font-weight: bold }
|
|
|
|
span.interpreted {
|
|
font-family: sans-serif }
|
|
|
|
span.option {
|
|
white-space: nowrap }
|
|
|
|
span.pre {
|
|
white-space: pre }
|
|
|
|
span.problematic {
|
|
color: red }
|
|
|
|
span.section-subtitle {
|
|
/* font-size relative to parent (h1..h6 element) */
|
|
font-size: 80% }
|
|
|
|
table.citation {
|
|
border-left: solid 1px gray;
|
|
margin-left: 1px }
|
|
|
|
table.docinfo {
|
|
margin: 2em 4em }
|
|
|
|
table.docutils {
|
|
margin-top: 0.5em ;
|
|
margin-bottom: 0.5em }
|
|
|
|
table.footnote {
|
|
border-left: solid 1px black;
|
|
margin-left: 1px }
|
|
|
|
table.docutils td, table.docutils th,
|
|
table.docinfo td, table.docinfo th {
|
|
padding-left: 0.5em ;
|
|
padding-right: 0.5em ;
|
|
vertical-align: top }
|
|
|
|
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
|
font-weight: bold ;
|
|
text-align: left ;
|
|
white-space: nowrap ;
|
|
padding-left: 0 }
|
|
|
|
/* "booktabs" style (no vertical lines) */
|
|
table.docutils.booktabs {
|
|
border: 0px;
|
|
border-top: 2px solid;
|
|
border-bottom: 2px solid;
|
|
border-collapse: collapse;
|
|
}
|
|
table.docutils.booktabs * {
|
|
border: 0px;
|
|
}
|
|
table.docutils.booktabs th {
|
|
border-bottom: thin solid;
|
|
text-align: left;
|
|
}
|
|
|
|
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
|
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
|
font-size: 100% }
|
|
|
|
ul.auto-toc {
|
|
list-style-type: none }
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="document" id="boost-pointer-container-library">
|
|
<h1 class="title"><img alt="Boost" src="boost.png" /> Pointer Container Library</h1>
|
|
<table class="docinfo" frame="void" rules="none">
|
|
<col class="docinfo-name" />
|
|
<col class="docinfo-content" />
|
|
<tbody valign="top">
|
|
<tr><th class="docinfo-name">Authors:</th>
|
|
<td>Thorsten Ottosen</td></tr>
|
|
<tr><th class="docinfo-name">Contact:</th>
|
|
<td><a class="first reference external" href="mailto:nesotto@cs.aau.dk">nesotto@cs.aau.dk</a> or <a class="last reference external" href="mailto:tottosen@dezide.com">tottosen@dezide.com</a></td></tr>
|
|
<tr class="organizations field"><th class="docinfo-name">Organizations:</th><td class="field-body"><a class="reference external" href="http://www.cs.aau.dk">Department of Computer Science</a>, Aalborg University, and <a class="reference external" href="http://www.dezide.com">Dezide Aps</a></td>
|
|
</tr>
|
|
<tr><th class="docinfo-name">Date:</th>
|
|
<td>27th of October 2007</td></tr>
|
|
<tr><th class="docinfo-name">Copyright:</th>
|
|
<td>Thorsten Ottosen 2004-2007. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt</a>).</td></tr>
|
|
</tbody>
|
|
</table>
|
|
<div class="section" id="overview">
|
|
<h1>Overview</h1>
|
|
<p>Boost.Pointer Container provides containers for holding heap-allocated
|
|
objects in an exception-safe manner and with minimal overhead.
|
|
The aim of the library is in particular to make OO programming
|
|
easier in C++ by establishing a standard set of classes, methods
|
|
and designs for dealing with OO specific problems</p>
|
|
<ul class="simple">
|
|
<li><a class="reference internal" href="#motivation">Motivation</a></li>
|
|
<li><a class="reference external" href="tutorial.html">Tutorial</a></li>
|
|
<li><a class="reference external" href="reference.html">Reference</a></li>
|
|
<li><a class="reference external" href="guidelines.html">Usage guidelines</a></li>
|
|
<li><a class="reference external" href="examples.html">Examples</a></li>
|
|
<li><a class="reference external" href="headers.html">Library headers</a></li>
|
|
<li><a class="reference external" href="faq.html">FAQ</a></li>
|
|
<li><a class="reference internal" href="#upgrading-from-boost-v-1-33">Upgrading from Boost v. 1.33.*</a></li>
|
|
<li><a class="reference internal" href="#upgrading-from-boost-v-1-34">Upgrading from Boost v. 1.34.*</a></li>
|
|
<li><a class="reference internal" href="#upgrading-from-boost-v-1-35">Upgrading from Boost v. 1.35.*</a></li>
|
|
<li><a class="reference internal" href="#upgrading-from-boost-v-1-66">Upgrading from Boost v. 1.66.*</a></li>
|
|
<li><a class="reference internal" href="#future-developments">Future Developments</a></li>
|
|
<li><a class="reference internal" href="#acknowledgements">Acknowledgements</a></li>
|
|
<li><a class="reference internal" href="#references">References</a></li>
|
|
</ul>
|
|
<!-- - `Conventions <conventions.html>`_
|
|
- `The Clonable Concept <reference.html#the-clonable-concept>`_
|
|
- `The Clone Allocator Concept <reference.html#the-clone-allocator-concept>`_
|
|
- `Pointer container adapters <reference.html#pointer-container-adapters>`_
|
|
- `Sequence container classes <reference.html#sequence-containers>`_
|
|
|
|
- `ptr_vector <ptr_vector.html>`_
|
|
- `ptr_deque <ptr_deque.html>`_
|
|
- `ptr_list <ptr_list.html>`_
|
|
- `ptr_array <ptr_array.html>`_
|
|
- `Associative container classes <reference.html#associative-containers>`_
|
|
|
|
- `ptr_set <ptr_set.html>`_
|
|
- `ptr_multiset <ptr_multiset.html>`_
|
|
- `ptr_map <ptr_map.html>`_
|
|
- `ptr_multimap <ptr_multimap.html>`_
|
|
- `Indirected functions <indirect_fun.html>`_
|
|
- `Class nullable <reference.html#class-nullable>`_
|
|
- `Exception classes <reference.html#exception-classes>`_ -->
|
|
</div>
|
|
<div class="section" id="motivation">
|
|
<h1>Motivation</h1>
|
|
<p>Whenever a programmer wants to have a container of pointers to
|
|
heap-allocated objects, there is usually only one exception-safe way:
|
|
to make a container of smart pointers like <a class="reference external" href="../../smart_ptr/shared_ptr.htm">boost::shared_ptr</a>
|
|
This approach is suboptimal if</p>
|
|
<ol class="arabic simple">
|
|
<li>the stored objects are not shared, but owned exclusively, or</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 external" href="reference.html#the-clonable-concept">cloned</a> objects (or in case of a map, the mapped object must be
|
|
a heap-allocated or cloned object). For each of the standard
|
|
containers there is a pointer container equivalent that takes ownership of
|
|
the objects in an exception safe manner. In this respect the library is intended
|
|
to solve the so-called
|
|
<a class="reference external" href="faq.html#what-is-the-polymorphic-class-problem">polymorphic class problem</a>.</p>
|
|
<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>
|
|
</ol>
|
|
<!-- -->
|
|
<ol class="arabic simple" start="4">
|
|
<li>No memory-overhead as containers of smart pointers can have (see <a class="footnote-reference" href="#id23" id="id2">[11]</a> and <a class="footnote-reference" href="#id25" id="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="#id23" id="id4">[11]</a> and <a class="footnote-reference" href="#id25" id="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">pop_back()</tt> to return the removed element.</li>
|
|
</ol>
|
|
<!-- -->
|
|
<ol class="arabic simple" start="7">
|
|
<li>Propagates constness such that one cannot modify the objects via a <tt class="docutils literal">const_iterator</tt>.</li>
|
|
</ol>
|
|
<!-- -->
|
|
<ol class="arabic simple" start="8">
|
|
<li>Built-in support for deep-copy semantics via the <a class="reference external" href="reference.html#the-clonable-concept">the Clonable 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 external" 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" id="upgrading-from-boost-v-1-33">
|
|
<h1>Upgrading from Boost v. <tt class="docutils literal">1.33.*</tt></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">transfer()</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 external" href="../../assign/index.html">Boost.Assign</a> introduces better support
|
|
for pointer containers.</p>
|
|
</div>
|
|
<div class="section" id="upgrading-from-boost-v-1-34">
|
|
<h1>Upgrading from Boost v. <tt class="docutils literal">1.34.*</tt></h1>
|
|
<p>Serialization has now been made optional thanks to Sebastian Ramacher.
|
|
You simply include <tt class="docutils literal"><boost/ptr_container/serialize.hpp></tt> or perhaps
|
|
just one of the more specialized headers.</p>
|
|
<p>All containers are now copy-constructible and assignable. So you can e.g. now
|
|
do:</p>
|
|
<pre class="literal-block">
|
|
boost::ptr_vector<Derived> derived = ...;
|
|
boost::ptr_vector<Base> base( derived );
|
|
base = derived;
|
|
</pre>
|
|
<p>As the example shows, derived-to-base class conversions are also allowed.</p>
|
|
<p>A few general functions have been added:</p>
|
|
<pre class="literal-block">
|
|
VoidPtrContainer& base();
|
|
const VoidPtrContainer& base() const;
|
|
</pre>
|
|
<p>These allow direct access to the wrapped container which is
|
|
sometimes needed when you want to provide extra functionality.</p>
|
|
<p>A few new functions have been added to sequences:</p>
|
|
<pre class="literal-block">
|
|
void resize( size_type size );
|
|
void resize( size_type size, T* to_clone );
|
|
</pre>
|
|
<p><tt class="docutils literal">ptr_vector<T></tt> has a few new helper functions to integrate better with C-arrays:</p>
|
|
<pre class="literal-block">
|
|
void transfer( iterator before, T** from, size_type size, bool delete_from = true );
|
|
T** c_array();
|
|
</pre>
|
|
<p>Finally, you can now also "copy" and "assign" an <tt class="docutils literal">auto_type</tt> ptr by calling <tt class="docutils literal">move()</tt>:</p>
|
|
<pre class="literal-block">
|
|
boost::ptr_vector<T>::auto_type move_ptr = ...;
|
|
return boost::ptr_container::move( move_ptr );
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="upgrading-from-boost-v-1-35">
|
|
<h1>Upgrading from Boost v. <tt class="docutils literal">1.35.*</tt></h1>
|
|
<p>The library has been fairly stable, but a few new containers have been supported:</p>
|
|
<ul class="simple">
|
|
<li><tt class="docutils literal"><span class="pre">boost::ptr_unordered_set<T></span></tt> in <tt class="docutils literal"><boost/ptr_container/ptr_unordered_set.hpp></tt></li>
|
|
<li><tt class="docutils literal"><span class="pre">boost::ptr_unordered_map<Key,T></span></tt> in <tt class="docutils literal"><boost/ptr_container/ptr_unordered_map.hpp></tt></li>
|
|
<li><tt class="docutils literal"><span class="pre">boost::ptr_circular_buffer<T></span></tt> in <tt class="docutils literal"><boost/ptr_container/ptr_circular_buffer.hpp></tt></li>
|
|
</ul>
|
|
<p>There are no docs for these classes yet, but they are almost identical to
|
|
<tt class="docutils literal"><span class="pre">boost::ptr_set<T></span></tt>, <tt class="docutils literal"><span class="pre">boost::ptr_map<Key,T></span></tt> and <tt class="docutils literal"><span class="pre">boost::ptr_array<T,N></span></tt>, respectively.
|
|
The underlying containers stem from the two boost libraries</p>
|
|
<ul class="simple">
|
|
<li><a class="reference external" href="../../unordered/index.html">Boost.Unordered</a></li>
|
|
<li><a class="reference external" href="../../circular_buffer/index.html">Boost.Circular Buffer</a></li>
|
|
</ul>
|
|
<p>Furthermore, <a class="reference external" href="ptr_inserter.html">insert iterators</a> have been added.</p>
|
|
</div>
|
|
<div class="section" id="upgrading-from-boost-v-1-66">
|
|
<h1>Upgrading from Boost v. <tt class="docutils literal">1.66.*</tt></h1>
|
|
<p>Starting with Boost v. <tt class="docutils literal">1.67.0</tt>, Boost.Pointer Container will use
|
|
<a class="reference external" href="../../config/index.html">Boost.Config</a> to conditionally provide
|
|
<tt class="docutils literal"><span class="pre">std::unique_ptr</span></tt>-based interfaces in addition to, or instead of,
|
|
interfaces using <tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt>. Details
|
|
are on the <a class="reference external" href="compatible_smart_ptr.html">Compatible Smart Pointer</a>
|
|
page, which also explains the convention in this documentation of using</p>
|
|
<pre class="literal-block">
|
|
<em>compatible-smart-ptr</em><T>
|
|
</pre>
|
|
<p>to indicate such conditional interfaces.</p>
|
|
<p>For C++98/03 users, this change has no observable effect.</p>
|
|
<p>For C++11/14 users, there is no effect on existing code that used
|
|
previous versions of Boost.Pointer Container, but now all function
|
|
overloads taking an <tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt> parameter are accompanied by an
|
|
overload taking <tt class="docutils literal"><span class="pre">std::unique_ptr</span></tt>. In the case of return types,
|
|
<tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt> is still always used. Note however that until C++17,
|
|
it is possible to construct <tt class="docutils literal"><span class="pre">std::unique_ptr<T></span></tt> implicitly from
|
|
<tt class="docutils literal"><span class="pre">std::auto_ptr<T></span></tt>. Thus, users are free to modernize their code by
|
|
replacing any explicit mention of <tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt> with
|
|
<tt class="docutils literal"><span class="pre">std::unique_ptr</span></tt>. This change falls just short of a
|
|
search-and-replace conversion, as it is possible that some code may
|
|
have relied on <tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt> being copyable. But such situations
|
|
will result in compile-time errors which should be easy to fix.</p>
|
|
<p>Although <tt class="docutils literal"><span class="pre">std::auto_ptr</span></tt> is formally removed as of ISO C++17,
|
|
certain compiler or standard library vendors have chosen to leave it
|
|
in for backwards compatibility. For compilers and standard libraries
|
|
where this is <em>not</em> the case, C++17 compilation of code using
|
|
Boost.Pointer Container is not possible with Boost v. <tt class="docutils literal">1.66.*</tt> or
|
|
earlier. This situation is fixed as of Boost v. <tt class="docutils literal">1.67.0</tt>.</p>
|
|
</div>
|
|
<div class="section" id="future-developments">
|
|
<h1>Future Developments</h1>
|
|
<p>There are indications that the <tt class="docutils literal">void*</tt> implementation has a slight
|
|
performance overhead compared to a <tt class="docutils literal">T*</tt> based implementation. Furthermore, a
|
|
<tt class="docutils literal">T*</tt> based implementation is so much easier to use type-safely
|
|
with algorithms. Therefore I anticipate to move to a <tt class="docutils literal">T*</tt> based implementation.</p>
|
|
<p>Furthermore, the clone allocator might be allowed to have state.
|
|
This design requires some thought, so if you have good ideas and use-cases'
|
|
for this, please don't hesitate to contact me.</p>
|
|
<p>Also, support for Boost.Interprocess is on the todo list.</p>
|
|
<p>There has been a few request for <tt class="docutils literal"><span class="pre">boost::ptr_multi_index_container<T,...></span></tt>.
|
|
I investigated how difficult it would be, and it did turn out to be difficult, albeit
|
|
not impossible. But I don't have the resources to implement this beast
|
|
for years to come, so if someone really needs this container, I suggest that they
|
|
talk with me in private about how it can be done.</p>
|
|
</div>
|
|
<div class="section" id="acknowledgements">
|
|
<h1>Acknowledgements</h1>
|
|
<p>The following people have been very helpful:</p>
|
|
<ul class="simple">
|
|
<li>Bjørn D. Rasmussen for unintentionally motivating me to start this library</li>
|
|
<li>Pavel Vozenilek for asking me to make the adapters</li>
|
|
<li>David Abrahams for the <tt class="docutils literal">indirect_fun</tt> design</li>
|
|
<li>Pavol Droba for being review manager</li>
|
|
<li>Ross Boylan for trying out a prototype for real</li>
|
|
<li>Felipe Magno de Almeida for giving fedback based on using the
|
|
library in production code even before the library was part of boost</li>
|
|
<li>Jonathan Turkanis for supplying his <tt class="docutils literal">move_ptr</tt> framework
|
|
which is used internally</li>
|
|
<li>Stefan Slapeta and Howard Hinnant for Metrowerks support</li>
|
|
<li>Russell Hind for help with Borland compatibility</li>
|
|
<li>Jonathan Wakely for his great help with GCC compatibility and bug fixes</li>
|
|
<li>Pavel Chikulaev for comments and bug-fixes</li>
|
|
<li>Andreas Hommel for fixing the nasty Metrowerks bug</li>
|
|
<li>Charles Brockman for his many comments on the documentation</li>
|
|
<li>Sebastian Ramacher for implementing the optional serialization support</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="references">
|
|
<h1>References</h1>
|
|
<table class="docutils footnote" frame="void" id="id8" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[1]</td><td>Matt Austern: <a class="reference external" 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="id10" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[2]</td><td>Bjarne Stroustrup, "The C++ Programming Language", <a class="reference external" 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="id12" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[3]</td><td>Herb Sutter, "Exceptional C++".</td></tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="docutils footnote" frame="void" id="id13" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[4]</td><td>Herb Sutter, "More Exceptional C++".</td></tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="docutils footnote" frame="void" id="id14" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[5]</td><td>Kevlin Henney: <a class="reference external" 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="id16" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[6]</td><td>Some of the few earlier attempts of pointer containers I have seen are the rather interesting <a class="reference external" href="http://www.ntllib.org/asp.html">NTL</a> and the
|
|
<a class="reference external" 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="id17" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[7]</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="id18" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[8]</td><td>C++ Standard Library Closed Issues List (Revision 27),
|
|
Item 218, <a class="reference external" href="http://www.open-std.org/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="id20" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[9]</td><td>C++ Standard Library Active Issues List (Revision 27),
|
|
Item 226, <a class="reference external" 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="id22" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[10]</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">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[11]</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 external" href="http://www.boost.org/libs/smart_ptr/smarttests.htm">timings</a></td></tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="docutils footnote" frame="void" id="id25" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[12]</td><td><em>(<a class="fn-backref" href="#id3">1</a>, <a class="fn-backref" href="#id5">2</a>)</em> <a class="reference external" href="http://www.ntllib.org/asp.html">NTL</a>: Array vs std::vector and boost::shared_ptr</td></tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="docutils footnote" frame="void" id="id26" rules="none">
|
|
<colgroup><col class="label" /><col /></colgroup>
|
|
<tbody valign="top">
|
|
<tr><td class="label">[13]</td><td>Kevlin Henney, <a class="reference external" 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">
|
|
<tr class="field"><th class="field-name">Copyright:</th><td class="field-body">Thorsten Ottosen 2004-2006.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|