• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
7<title>Boost Pointer Container Library</title>
8<style type="text/css">
9
10/*
11:Author: David Goodger (goodger@python.org)
12:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
13:Copyright: This stylesheet has been placed in the public domain.
14
15Default cascading style sheet for the HTML output of Docutils.
16
17See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
18customize this style sheet.
19*/
20
21/* used to remove borders from tables and images */
22.borderless, table.borderless td, table.borderless th {
23  border: 0 }
24
25table.borderless td, table.borderless th {
26  /* Override padding for "table.docutils td" with "! important".
27     The right padding separates the table cells. */
28  padding: 0 0.5em 0 0 ! important }
29
30.first {
31  /* Override more specific margin styles with "! important". */
32  margin-top: 0 ! important }
33
34.last, .with-subtitle {
35  margin-bottom: 0 ! important }
36
37.hidden {
38  display: none }
39
40.subscript {
41  vertical-align: sub;
42  font-size: smaller }
43
44.superscript {
45  vertical-align: super;
46  font-size: smaller }
47
48a.toc-backref {
49  text-decoration: none ;
50  color: black }
51
52blockquote.epigraph {
53  margin: 2em 5em ; }
54
55dl.docutils dd {
56  margin-bottom: 0.5em }
57
58object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
59  overflow: hidden;
60}
61
62/* Uncomment (and remove this text!) to get bold-faced definition list terms
63dl.docutils dt {
64  font-weight: bold }
65*/
66
67div.abstract {
68  margin: 2em 5em }
69
70div.abstract p.topic-title {
71  font-weight: bold ;
72  text-align: center }
73
74div.admonition, div.attention, div.caution, div.danger, div.error,
75div.hint, div.important, div.note, div.tip, div.warning {
76  margin: 2em ;
77  border: medium outset ;
78  padding: 1em }
79
80div.admonition p.admonition-title, div.hint p.admonition-title,
81div.important p.admonition-title, div.note p.admonition-title,
82div.tip p.admonition-title {
83  font-weight: bold ;
84  font-family: sans-serif }
85
86div.attention p.admonition-title, div.caution p.admonition-title,
87div.danger p.admonition-title, div.error p.admonition-title,
88div.warning p.admonition-title, .code .error {
89  color: red ;
90  font-weight: bold ;
91  font-family: sans-serif }
92
93/* Uncomment (and remove this text!) to get reduced vertical space in
94   compound paragraphs.
95div.compound .compound-first, div.compound .compound-middle {
96  margin-bottom: 0.5em }
97
98div.compound .compound-last, div.compound .compound-middle {
99  margin-top: 0.5em }
100*/
101
102div.dedication {
103  margin: 2em 5em ;
104  text-align: center ;
105  font-style: italic }
106
107div.dedication p.topic-title {
108  font-weight: bold ;
109  font-style: normal }
110
111div.figure {
112  margin-left: 2em ;
113  margin-right: 2em }
114
115div.footer, div.header {
116  clear: both;
117  font-size: smaller }
118
119div.line-block {
120  display: block ;
121  margin-top: 1em ;
122  margin-bottom: 1em }
123
124div.line-block div.line-block {
125  margin-top: 0 ;
126  margin-bottom: 0 ;
127  margin-left: 1.5em }
128
129div.sidebar {
130  margin: 0 0 0.5em 1em ;
131  border: medium outset ;
132  padding: 1em ;
133  background-color: #ffffee ;
134  width: 40% ;
135  float: right ;
136  clear: right }
137
138div.sidebar p.rubric {
139  font-family: sans-serif ;
140  font-size: medium }
141
142div.system-messages {
143  margin: 5em }
144
145div.system-messages h1 {
146  color: red }
147
148div.system-message {
149  border: medium outset ;
150  padding: 1em }
151
152div.system-message p.system-message-title {
153  color: red ;
154  font-weight: bold }
155
156div.topic {
157  margin: 2em }
158
159h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
160h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
161  margin-top: 0.4em }
162
163h1.title {
164  text-align: center }
165
166h2.subtitle {
167  text-align: center }
168
169hr.docutils {
170  width: 75% }
171
172img.align-left, .figure.align-left, object.align-left, table.align-left {
173  clear: left ;
174  float: left ;
175  margin-right: 1em }
176
177img.align-right, .figure.align-right, object.align-right, table.align-right {
178  clear: right ;
179  float: right ;
180  margin-left: 1em }
181
182img.align-center, .figure.align-center, object.align-center {
183  display: block;
184  margin-left: auto;
185  margin-right: auto;
186}
187
188table.align-center {
189  margin-left: auto;
190  margin-right: auto;
191}
192
193.align-left {
194  text-align: left }
195
196.align-center {
197  clear: both ;
198  text-align: center }
199
200.align-right {
201  text-align: right }
202
203/* reset inner alignment in figures */
204div.align-right {
205  text-align: inherit }
206
207/* div.align-center * { */
208/*   text-align: left } */
209
210.align-top    {
211  vertical-align: top }
212
213.align-middle {
214  vertical-align: middle }
215
216.align-bottom {
217  vertical-align: bottom }
218
219ol.simple, ul.simple {
220  margin-bottom: 1em }
221
222ol.arabic {
223  list-style: decimal }
224
225ol.loweralpha {
226  list-style: lower-alpha }
227
228ol.upperalpha {
229  list-style: upper-alpha }
230
231ol.lowerroman {
232  list-style: lower-roman }
233
234ol.upperroman {
235  list-style: upper-roman }
236
237p.attribution {
238  text-align: right ;
239  margin-left: 50% }
240
241p.caption {
242  font-style: italic }
243
244p.credits {
245  font-style: italic ;
246  font-size: smaller }
247
248p.label {
249  white-space: nowrap }
250
251p.rubric {
252  font-weight: bold ;
253  font-size: larger ;
254  color: maroon ;
255  text-align: center }
256
257p.sidebar-title {
258  font-family: sans-serif ;
259  font-weight: bold ;
260  font-size: larger }
261
262p.sidebar-subtitle {
263  font-family: sans-serif ;
264  font-weight: bold }
265
266p.topic-title {
267  font-weight: bold }
268
269pre.address {
270  margin-bottom: 0 ;
271  margin-top: 0 ;
272  font: inherit }
273
274pre.literal-block, pre.doctest-block, pre.math, pre.code {
275  margin-left: 2em ;
276  margin-right: 2em }
277
278pre.code .ln { color: grey; } /* line numbers */
279pre.code, code { background-color: #eeeeee }
280pre.code .comment, code .comment { color: #5C6576 }
281pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
282pre.code .literal.string, code .literal.string { color: #0C5404 }
283pre.code .name.builtin, code .name.builtin { color: #352B84 }
284pre.code .deleted, code .deleted { background-color: #DEB0A1}
285pre.code .inserted, code .inserted { background-color: #A3D289}
286
287span.classifier {
288  font-family: sans-serif ;
289  font-style: oblique }
290
291span.classifier-delimiter {
292  font-family: sans-serif ;
293  font-weight: bold }
294
295span.interpreted {
296  font-family: sans-serif }
297
298span.option {
299  white-space: nowrap }
300
301span.pre {
302  white-space: pre }
303
304span.problematic {
305  color: red }
306
307span.section-subtitle {
308  /* font-size relative to parent (h1..h6 element) */
309  font-size: 80% }
310
311table.citation {
312  border-left: solid 1px gray;
313  margin-left: 1px }
314
315table.docinfo {
316  margin: 2em 4em }
317
318table.docutils {
319  margin-top: 0.5em ;
320  margin-bottom: 0.5em }
321
322table.footnote {
323  border-left: solid 1px black;
324  margin-left: 1px }
325
326table.docutils td, table.docutils th,
327table.docinfo td, table.docinfo th {
328  padding-left: 0.5em ;
329  padding-right: 0.5em ;
330  vertical-align: top }
331
332table.docutils th.field-name, table.docinfo th.docinfo-name {
333  font-weight: bold ;
334  text-align: left ;
335  white-space: nowrap ;
336  padding-left: 0 }
337
338/* "booktabs" style (no vertical lines) */
339table.docutils.booktabs {
340  border: 0px;
341  border-top: 2px solid;
342  border-bottom: 2px solid;
343  border-collapse: collapse;
344}
345table.docutils.booktabs * {
346  border: 0px;
347}
348table.docutils.booktabs th {
349  border-bottom: thin solid;
350  text-align: left;
351}
352
353h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
354h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
355  font-size: 100% }
356
357ul.auto-toc {
358  list-style-type: none }
359
360</style>
361</head>
362<body>
363<div class="document" id="boost-pointer-container-library">
364<h1 class="title"><img alt="Boost" src="boost.png" /> Pointer Container Library</h1>
365<h2 class="subtitle" id="conventions">Conventions</h2>
366
367<p>There are a few design decisions that will affect how the classes are
368used.  Besides these the classes are much like normal standard containers
369and provides almost the same interface.  The new conventions are:</p>
370<div class="contents local topic" id="contents">
371<ul class="simple">
372<li><a class="reference internal" href="#null-pointers-are-not-allowed-by-default" id="id3">Null pointers are not allowed by default</a></li>
373<li><a class="reference internal" href="#all-default-iterators-apply-an-extra-layer-of-indirection" id="id4">All default iterators apply an extra layer of indirection</a></li>
374<li><a class="reference internal" href="#all-comparison-operations-are-done-on-the-pointed-to-objects-and-not-at-the-pointer-level" id="id5">All comparison operations are done on the pointed to objects and not at the pointer level</a></li>
375<li><a class="reference internal" href="#stored-elements-are-required-to-be-cloneable-for-a-subset-of-the-operations" id="id6">Stored elements are required to be Cloneable for a subset of the operations</a></li>
376<li><a class="reference internal" href="#whenever-objects-are-inserted-into-a-container-they-are-cloned-before-insertion" id="id7">Whenever objects are inserted into a container, they are cloned before insertion</a></li>
377<li><a class="reference internal" href="#whenever-pointers-are-inserted-into-a-container-ownership-is-transferred-to-the-container" id="id8">Whenever pointers are inserted into a container, ownership is transferred to the container</a></li>
378<li><a class="reference internal" href="#ownership-can-be-transferred-from-a-container-on-a-per-pointer-basis" id="id9">Ownership can be transferred from a container on a per pointer basis</a></li>
379<li><a class="reference internal" href="#ownership-can-be-transferred-from-a-container-to-another-container-on-a-per-iterator-range-basis" id="id10">Ownership can be transferred from a container to another container on a per iterator range basis</a></li>
380<li><a class="reference internal" href="#a-container-can-be-cheaply-returned-from-functions-either-by-making-a-clone-or-by-giving-up-ownership-of-the-container" id="id11">A container can be cheaply returned from functions either by making a clone or by giving up ownership of the container</a></li>
381<li><a class="reference internal" href="#iterators-are-invalidated-as-in-the-corresponding-standard-container" id="id12">Iterators are invalidated as in the corresponding standard container</a></li>
382</ul>
383</div>
384<div class="section" id="null-pointers-are-not-allowed-by-default">
385<h1><a class="toc-backref" href="#id3">Null pointers are not allowed by default</a></h1>
386<p>If the user tries to insert the null pointer, the operation will throw a
387<tt class="docutils literal">bad_pointer</tt> exception (see <a class="reference external" href="examples.html">Example 1</a>).</p>
388<p>Use <a class="reference external" href="reference.html#class-nullable">nullable</a> to allow null pointers.</p>
389<p>Please notice that all preconditions of the form</p>
390<pre class="literal-block">
391x != 0;
392</pre>
393<p>are not active when the you have instantiated a container
394with <tt class="docutils literal">nullable&lt;T&gt;</tt> as in</p>
395<pre class="literal-block">
396boost::ptr_vector&lt; boost::nullable&lt;animal&gt; &gt; vec;
397vec.push_back( 0 ); // ok
398</pre>
399</div>
400<div class="section" id="all-default-iterators-apply-an-extra-layer-of-indirection">
401<h1><a class="toc-backref" href="#id4">All default iterators apply an extra layer of indirection</a></h1>
402<p>This is done to
403make the containers easier and safer to use.  It promotes a kind of
404pointer-less programming and the user of a class needs not worry about
405pointers except when allocating them (see <a class="reference external" href="examples.html">Example 2</a>).  Iterators that
406provide access to the naked pointers are also provided since they might be
407useful in rare cases. For example, whenever <tt class="docutils literal">begin()</tt> returns an iterator,
408<tt class="docutils literal">ptr_begin()</tt> will return an iterator that allows one to iterate over the
409stored pointers.</p>
410</div>
411<div class="section" id="all-comparison-operations-are-done-on-the-pointed-to-objects-and-not-at-the-pointer-level">
412<h1><a class="toc-backref" href="#id5">All comparison operations are done on the pointed to objects and not at the pointer level</a></h1>
413<p>For example, in <tt class="docutils literal">ptr_set&lt;T&gt;</tt> the ordering is by default done by
414<tt class="docutils literal"><span class="pre">boost::ptr_less&lt;T&gt;</span></tt> which compares the indirected pointers.
415Similarly, <tt class="docutils literal"><span class="pre">operator==()</span></tt> for <tt class="docutils literal">container&lt;Foo&gt;</tt> compares all objects
416with <tt class="docutils literal"><span class="pre">operator==(const</span> Foo&amp;, const Foo&amp;)</tt>.</p>
417</div>
418<div class="section" id="stored-elements-are-required-to-be-cloneable-for-a-subset-of-the-operations">
419<h1>Stored elements are required to be <a class="reference external" href="reference.html#the-Cloneable-concept">Cloneable</a> for a subset of the operations</h1>
420<p>This is because most polymorphic objects cannot be copied directly, but
421they can often be so by a use of a member function (see <a class="reference external" href="examples.html">Example 4</a>).  Often
422it does not even make sense to clone an object in which case a large
423subset of the operations are still workable.</p>
424</div>
425<div class="section" id="whenever-objects-are-inserted-into-a-container-they-are-cloned-before-insertion">
426<h1><a class="toc-backref" href="#id7">Whenever objects are inserted into a container, they are cloned before insertion</a></h1>
427<p>This is necessary because all pointer containers take ownerships of stored objects
428(see <a class="reference external" href="examples.html">Example 5</a>).</p>
429</div>
430<div class="section" id="whenever-pointers-are-inserted-into-a-container-ownership-is-transferred-to-the-container">
431<h1><a class="toc-backref" href="#id8">Whenever pointers are inserted into a container, ownership is transferred to the container</a></h1>
432<p>All containers take ownership of the stored pointers and therefore a
433container needs to have its own copies (see <a class="reference external" href="examples.html">Example 5</a>).</p>
434</div>
435<div class="section" id="ownership-can-be-transferred-from-a-container-on-a-per-pointer-basis">
436<h1><a class="toc-backref" href="#id9">Ownership can be transferred from a container on a per pointer basis</a></h1>
437<p>This can of course also be convenient.  Whenever it happens, an
438<tt class="docutils literal"><span class="pre">SmartContainer::auto_type</span></tt> object is used to provide an exception-safe transfer
439(see <a class="reference external" href="examples.html">Example 6</a>).</p>
440</div>
441<div class="section" id="ownership-can-be-transferred-from-a-container-to-another-container-on-a-per-iterator-range-basis">
442<h1><a class="toc-backref" href="#id10">Ownership can be transferred from a container to another container on a per iterator range basis</a></h1>
443<p>This makes it possible to exchange data safely between different pointer
444containers without cloning the objects again (see <a class="reference external" href="examples.html">Example 7</a>).</p>
445</div>
446<div class="section" id="a-container-can-be-cheaply-returned-from-functions-either-by-making-a-clone-or-by-giving-up-ownership-of-the-container">
447<h1><a class="toc-backref" href="#id11">A container can be cheaply returned from functions either by making a clone or by giving up ownership of the container</a></h1>
448<p>Two special member functions, <tt class="docutils literal">clone()</tt> and <tt class="docutils literal">release()</tt>, both return a
449<tt class="docutils literal"><span class="pre"><a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a>&lt;SmartContainer&gt;</span></tt> which can be assigned to another pointer container.  This
450effectively reduces the cost of returning a container to one
451heap-allocation plus a call to <tt class="docutils literal">swap()</tt> (see <a class="reference external" href="examples.html">Example 3</a>).</p>
452</div>
453<div class="section" id="iterators-are-invalidated-as-in-the-corresponding-standard-container">
454<h1><a class="toc-backref" href="#id12">Iterators are invalidated as in the corresponding standard container</a></h1>
455<p>Because the containers in this library wrap standard containers, the
456rules for invalidation of iterators are the same as the rules
457of the corresponding standard container.</p>
458<p>For example, for both <tt class="docutils literal"><span class="pre">boost::ptr_vector&lt;T&gt;</span></tt> and <tt class="docutils literal"><span class="pre">std::vector&lt;U&gt;</span></tt>
459insertion and deletion only invalidates the deleted
460element and elements following it; all elements before the inserted/deleted
461element remain valid.</p>
462<hr><p><strong>Navigate:</strong></p>
463<ul class="simple">
464<li><a class="reference external" href="ptr_container.html">home</a></li>
465<li><a class="reference external" href="reference.html">reference</a></li>
466</ul>
467<hr><table class="docutils field-list" frame="void" rules="none">
468<col class="field-name" />
469<col class="field-body" />
470<tbody valign="top">
471<tr class="field"><th class="field-name">Copyright:</th><td class="field-body">Thorsten Ottosen 2004-2006. 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>
472</tr>
473</tbody>
474</table>
475</div>
476</div>
477</body>
478</html>
479