Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / ptr_container / doc / reversible_ptr_container.html
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.3.10: http://docutils.sourceforge.net/" />
7 <title>Boost Pointer Container Library</title>
8 <style type="text/css">
9
10 /*
11 :Author: David Goodger
12 :Contact: goodger@users.sourceforge.net
13 :Date: $Date$
14 :Revision: $Revision$
15 :Copyright: This stylesheet has been placed in the public domain.
16
17 Default cascading style sheet for the HTML output of Docutils.
18
19 See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
20 customize this style sheet.
21 */
22
23 /* "! important" is used here to override other ``margin-top`` and
24    ``margin-bottom`` styles that are later in the stylesheet or 
25    more specific.  See http://www.w3.org/TR/CSS1#the-cascade */
26 .first {
27   margin-top: 0 ! important }
28
29 .last, .with-subtitle {
30   margin-bottom: 0 ! important }
31
32 .hidden {
33   display: none }
34
35 a.toc-backref {
36   text-decoration: none ;
37   color: black }
38
39 blockquote.epigraph {
40   margin: 2em 5em ; }
41
42 dl.docutils dd {
43   margin-bottom: 0.5em }
44
45 /* Uncomment (and remove this text!) to get bold-faced definition list terms
46 dl.docutils dt {
47   font-weight: bold }
48 */
49
50 div.abstract {
51   margin: 2em 5em }
52
53 div.abstract p.topic-title {
54   font-weight: bold ;
55   text-align: center }
56
57 div.admonition, div.attention, div.caution, div.danger, div.error,
58 div.hint, div.important, div.note, div.tip, div.warning {
59   margin: 2em ;
60   border: medium outset ;
61   padding: 1em }
62
63 div.admonition p.admonition-title, div.hint p.admonition-title,
64 div.important p.admonition-title, div.note p.admonition-title,
65 div.tip p.admonition-title {
66   font-weight: bold ;
67   font-family: sans-serif }
68
69 div.attention p.admonition-title, div.caution p.admonition-title,
70 div.danger p.admonition-title, div.error p.admonition-title,
71 div.warning p.admonition-title {
72   color: red ;
73   font-weight: bold ;
74   font-family: sans-serif }
75
76 /* Uncomment (and remove this text!) to get reduced vertical space in
77    compound paragraphs.
78 div.compound .compound-first, div.compound .compound-middle {
79   margin-bottom: 0.5em }
80
81 div.compound .compound-last, div.compound .compound-middle {
82   margin-top: 0.5em }
83 */
84
85 div.dedication {
86   margin: 2em 5em ;
87   text-align: center ;
88   font-style: italic }
89
90 div.dedication p.topic-title {
91   font-weight: bold ;
92   font-style: normal }
93
94 div.figure {
95   margin-left: 2em }
96
97 div.footer, div.header {
98   clear: both;
99   font-size: smaller }
100
101 div.line-block {
102   display: block ;
103   margin-top: 1em ;
104   margin-bottom: 1em }
105
106 div.line-block div.line-block {
107   margin-top: 0 ;
108   margin-bottom: 0 ;
109   margin-left: 1.5em }
110
111 div.sidebar {
112   margin-left: 1em ;
113   border: medium outset ;
114   padding: 1em ;
115   background-color: #ffffee ;
116   width: 40% ;
117   float: right ;
118   clear: right }
119
120 div.sidebar p.rubric {
121   font-family: sans-serif ;
122   font-size: medium }
123
124 div.system-messages {
125   margin: 5em }
126
127 div.system-messages h1 {
128   color: red }
129
130 div.system-message {
131   border: medium outset ;
132   padding: 1em }
133
134 div.system-message p.system-message-title {
135   color: red ;
136   font-weight: bold }
137
138 div.topic {
139   margin: 2em }
140
141 h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
142 h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
143   margin-top: 0.4em }
144
145 h1.title {
146   text-align: center }
147
148 h2.subtitle {
149   text-align: center }
150
151 hr.docutils {
152   width: 75% }
153
154 img.align-left {
155   clear: left }
156
157 img.align-right {
158   clear: right }
159
160 img.borderless {
161   border: 0 }
162
163 ol.simple, ul.simple {
164   margin-bottom: 1em }
165
166 ol.arabic {
167   list-style: decimal }
168
169 ol.loweralpha {
170   list-style: lower-alpha }
171
172 ol.upperalpha {
173   list-style: upper-alpha }
174
175 ol.lowerroman {
176   list-style: lower-roman }
177
178 ol.upperroman {
179   list-style: upper-roman }
180
181 p.attribution {
182   text-align: right ;
183   margin-left: 50% }
184
185 p.caption {
186   font-style: italic }
187
188 p.credits {
189   font-style: italic ;
190   font-size: smaller }
191
192 p.label {
193   white-space: nowrap }
194
195 p.rubric {
196   font-weight: bold ;
197   font-size: larger ;
198   color: maroon ;
199   text-align: center }
200
201 p.sidebar-title {
202   font-family: sans-serif ;
203   font-weight: bold ;
204   font-size: larger }
205
206 p.sidebar-subtitle {
207   font-family: sans-serif ;
208   font-weight: bold }
209
210 p.topic-title {
211   font-weight: bold }
212
213 pre.address {
214   margin-bottom: 0 ;
215   margin-top: 0 ;
216   font-family: serif ;
217   font-size: 100% }
218
219 pre.line-block {
220   font-family: serif ;
221   font-size: 100% }
222
223 pre.literal-block, pre.doctest-block {
224   margin-left: 2em ;
225   margin-right: 2em ;
226   background-color: #eeeeee }
227
228 span.classifier {
229   font-family: sans-serif ;
230   font-style: oblique }
231
232 span.classifier-delimiter {
233   font-family: sans-serif ;
234   font-weight: bold }
235
236 span.interpreted {
237   font-family: sans-serif }
238
239 span.option {
240   white-space: nowrap }
241
242 span.pre {
243   white-space: pre }
244
245 span.problematic {
246   color: red }
247
248 span.section-subtitle {
249   /* font-size relative to parent (h1..h6 element) */
250   font-size: 80% }
251
252 table.citation {
253   border-left: solid thin gray }
254
255 table.docinfo {
256   margin: 2em 4em }
257
258 table.docutils {
259   margin-top: 0.5em ;
260   margin-bottom: 0.5em }
261
262 table.footnote {
263   border-left: solid thin black }
264
265 table.docutils td, table.docutils th,
266 table.docinfo td, table.docinfo th {
267   padding-left: 0.5em ;
268   padding-right: 0.5em ;
269   vertical-align: top }
270
271 table.docutils th.field-name, table.docinfo th.docinfo-name {
272   font-weight: bold ;
273   text-align: left ;
274   white-space: nowrap ;
275   padding-left: 0 }
276
277 h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
278 h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
279   font-size: 100% }
280
281 tt.docutils {
282   background-color: #eeeeee }
283
284 ul.auto-toc {
285   list-style-type: none }
286
287 </style>
288 </head>
289 <body>
290 <div class="document" id="boost-pointer-container-library">
291 <h1 class="title"><img alt="Boost" src="boost.png" /> Pointer Container Library</h1>
292 <div class="section">
293 <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>
294 <p>This class is not a real class that can be found in the library. 
295 Its purpose is to present the general interface of all the pointer containers.</p>
296 <p><strong>Hierarchy:</strong></p>
297 <ul class="simple">
298 <li><tt class="docutils literal"><span class="pre">reversible_ptr_container</span></tt><ul>
299 <li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul>
300 <li><a class="reference" href="ptr_vector.html">ptr_vector</a></li>
301 <li><a class="reference" href="ptr_list.html">ptr_list</a></li>
302 <li><a class="reference" href="ptr_deque.html">ptr_deque</a></li>
303 <li><a class="reference" href="ptr_array.html">ptr_array</a></li>
304 </ul>
305 </li>
306 <li><a class="reference" href="associative_ptr_container.html">associative_ptr_container</a><ul>
307 <li><a class="reference" href="ptr_set_adapter.html">ptr_set_adapter</a></li>
308 <li><a class="reference" href="ptr_multiset_adapter.html">ptr_multiset_adapter</a></li>
309 <li><a class="reference" href="ptr_map_adapter.html">ptr_map_adapter</a></li>
310 <li><a class="reference" href="ptr_multimap_adapter.html">ptr_multi_map_adapter</a><ul>
311 <li><a class="reference" href="ptr_set.html">ptr_set</a></li>
312 <li><a class="reference" href="ptr_multiset.html">ptr_multi_set</a></li>
313 <li><a class="reference" href="ptr_map.html">ptr_map</a></li>
314 <li><a class="reference" href="ptr_multimap.html">ptr_multimap</a></li>
315 </ul>
316 </li>
317 </ul>
318 </li>
319 </ul>
320 </li>
321 </ul>
322 <p><strong>Navigate:</strong></p>
323 <ul class="simple">
324 <li><a class="reference" href="ptr_container.html">home</a></li>
325 <li><a class="reference" href="reference.html">reference</a></li>
326 </ul>
327 <p><strong>synopsis:</strong></p>
328 <pre class="literal-block">
329 namespace boost
330 {      
331     template
332     &lt; 
333         class T, 
334         class CloneAllocator,
335         class VoidPtrContainer
336     &gt;
337     class reversible_ptr_container 
338     {
339     public: // <a class="reference" href="#typedefs">typedefs</a>
340         typedef  T*                                           value_type;
341         typedef  T&amp;                                           reference;
342         typedef  const T&amp;                                     const_reference;
343         typedef  <em>implementation defined</em>                       iterator;
344         typedef  <em>implementation defined</em>                       const_iterator;
345         typedef  typename VoidPtrContainer::differnce_type    difference_type; 
346         typedef  typename VoidPtrContainer::size_type         size_type;
347         typedef  typename VoidPtrContainer::allocator_type    allocator_type;
348         typedef  <em>implementation defined</em>                       reverse_iterator;
349         typedef  <em>implementation defined</em>                       const_reverse_iterator;
350         typedef  <em>implementation defined</em>                       auto_type;
351     
352     public: // <a class="reference" href="#construct-copy-destroy">construct/copy/destroy</a>
353         reversible_ptr_container();
354         explicit reversible_ptr_container( const reversible_ptr_container&amp; r );                
355         template&lt; class Derived &gt;
356         explicit reversible_ptr_container( const reversible_ptr_container&lt;Derived&gt;&amp; r );
357         explicit reversible_ptr_container( std::auto_ptr&lt;reversible_ptr_container&gt; r );
358         template&lt; class InputIterator &gt;
359         reversible_ptr_container( InputIterator first, InputIterator last );
360         
361         ~reversible_ptr_container();
362
363         reversible_ptr_container&amp;  operator=( const reversible_ptr_container&amp; r );
364         template&lt;class Derived&gt;
365         reversible_ptr_container&amp;  operator=( const reversible_ptr_container&lt;Derived&gt;&amp; r );
366         reversible_ptr_container&amp;  operator=( std::auto_ptr&lt;reversible_ptr_container&gt; r );
367         allocator_type             get_allocator() const;                                      
368     
369     public: // <a class="reference" href="#iterators">iterators</a>
370         iterator                begin();
371         const_iterator          begin() const;
372         iterator                end();
373         const_iterator          end() const;
374         reverse_iterator        rbegin();
375         const_reverse_iterator  rbegin() const;
376         reverse_iterator        rend();
377         const_reverse_iterator  rend() const;
378         
379     public: // <a class="reference" href="#capacity">capacity</a>
380         size_type  size() const;
381         size_type  max_size() const;
382         bool       empty() const;       
383     
384     public: // <a class="reference" href="#modifiers">modifiers</a>
385         void                     swap( reversible_ptr_container&amp; r );
386         void                     clear():
387         VoidPtrContainer&amp;        base();
388         const VoidPtrContainer&amp;  base() const;
389     
390     public: // <a class="reference" href="#pointer-container-requirements">pointer container requirements</a>
391         auto_type                                replace( iterator position, T* x );
392         template&lt; class U &gt;
393         auto_type                                replace( iterator position, std::auto_ptr&lt;U&gt; x );    
394         std::auto_ptr&lt;reversible_ptr_container&gt;  clone() const;    
395         std::auto_ptr&lt;reversible_ptr_container&gt;  release();
396         auto_type                                release( iterator position );
397                     
398     }; //  class 'reversible_ptr_container'
399
400     // <a class="reference" href="#comparison">comparison</a>            
401     template &lt; class T, class CA, class VPC &gt;
402     bool operator==( const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; x,
403                      const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; y);
404     
405     template &lt; class T, class CA, class VPC  &gt;
406     bool operator&lt;( const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; x,
407                     const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; y);
408     
409     template &lt; class T, class CA, class VPC  &gt;
410     bool operator!=( const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; x,
411                      const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; y);
412     
413     template &lt; class T,  class CA, class VPC &gt;
414     bool operator&gt;( const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; x,
415                     const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; y);
416     
417     template &lt; class T,  class CA, class VPC &gt;
418     bool operator&gt;=( const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; x,
419                      const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; y);
420     
421     template &lt; class T,  class CA, class VPC &gt;
422     bool operator&lt;=( const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; x,
423                      const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; y);
424
425     template&lt; class T,  class CA, class VPC  &gt;
426     void swap( reversible_ptr_container&lt;T,CA,VPC&gt;&amp; x,
427                reversible_ptr_container&lt;T,CA,VPC&gt;&amp; y );
428
429     // <a class="reference" href="#cloneability">cloneability</a>
430     template&lt; class T,  class CA, class VPC &gt;
431     reversible_ptr_container&lt;T,CA,VPC&gt;*
432     new_clone( const reversible_ptr_container&lt;T,CA,VPC&gt;&amp; r );
433
434     // <a class="reference" href="#null-predicate">null predicate</a>
435     template&lt; class Iterator &gt;
436     bool is_null( Iterator i );
437     
438     // <a class="reference" href="#serialization">serialization</a>
439     template&lt;class Archive, class T, class CA, class VPC&gt;
440     void serialize( Archive&amp; ar, reversible_ptr_container&lt;T,CÁ,VPC&gt;&amp; c, const unsigned int version );
441
442
443 } // namespace 'boost'
444 </pre>
445 </div>
446 <div class="section">
447 <h1><a id="semantics" name="semantics">Semantics</a></h1>
448 <div class="section">
449 <h2><a id="semantics-typedefs" name="semantics-typedefs"><span id="typedefs"></span>Semantics: typedefs</a></h2>
450 <p>Notice how these two types differ:</p>
451 <ul>
452 <li><p class="first"><tt class="docutils literal"><span class="pre">typedef</span> <span class="pre">T*</span> <span class="pre">value_type;</span></tt></p>
453 <blockquote>
454 <ul class="simple">
455 <li>notice this has pointer type</li>
456 </ul>
457 </blockquote>
458 </li>
459 <li><p class="first"><tt class="docutils literal"><span class="pre">typedef</span> <span class="pre">T&amp;</span> <span class="pre">reference;</span></tt></p>
460 <blockquote>
461 <ul class="simple">
462 <li>notice this is not a pointer type</li>
463 </ul>
464 </blockquote>
465 </li>
466 </ul>
467 <p>This is done to be able to add pointers directly
468 to the container, but to hide the pointers externally.</p>
469 <!-- - ``typedef *implementation defined* object_type;``
470 - this is ``T`` for sequences and sets
471 - this is ``std::pair<const Key, void*>`` for maps -->
472 <p>Also notice that</p>
473 <ul class="simple">
474 <li><tt class="docutils literal"><span class="pre">typedef</span> <span class="pre">...</span> <span class="pre">iterator</span></tt></li>
475 </ul>
476 <p>allows one to iterate over <tt class="docutils literal"><span class="pre">T&amp;</span></tt> objects, not <tt class="docutils literal"><span class="pre">T*</span></tt>.
477 Note that:</p>
478 <pre class="literal-block">
479 iterator i = ...;
480 i.base();
481 </pre>
482 <p>returns an iterator that allows one to iterate over <tt class="docutils literal"><span class="pre">void*</span></tt>
483 elements (<em>this is very rarely needed and you should not use the
484 functionality unless you know what you are doing</em>).</p>
485 <ul class="simple">
486 <li><tt class="docutils literal"><span class="pre">typedef</span> <span class="pre">...</span> <span class="pre">auto_type</span></tt></li>
487 </ul>
488 <p>This declaration hides a pointer pointer type. You can rely on the following
489 operations</p>
490 <pre class="literal-block">
491 T* operator-&gt;() const;
492 T&amp; operator*() const;
493 T* release();
494 ~auto_type();
495 operator <em>implementation-defined bool</em>();
496 </pre>
497 <p>The destructor will delete the stored object <em>using the clone allocator of the container</em>
498 (this explains why we cannot use <tt class="docutils literal"><span class="pre">std::auto_ptr&lt;T&gt;</span></tt>). It might help to
499 think it is just an <tt class="docutils literal"><span class="pre">std::auto_ptr&lt;T&gt;</span></tt>. You can also return
500 the pointer from a function or assign it to another pointer via the <tt class="docutils literal"><span class="pre">move()</span></tt>
501 function</p>
502 <pre class="literal-block">
503 auto_type ptr   = ...;
504 auto_type other = boost::ptr_container::move( ptr );
505 return boost::ptr_container::move( other );
506 </pre>
507 </div>
508 <div class="section">
509 <h2><a id="semantics-construct-copy-destroy" name="semantics-construct-copy-destroy"><span id="construct-copy-destroy"></span>Semantics: construct/copy/destroy</a></h2>
510 <ul>
511 <li><p class="first"><tt class="docutils literal"><span class="pre">reversible_ptr_container();</span></tt></p>
512 <blockquote>
513 <ul class="simple">
514 <li>Effects: Constructs an empty container</li>
515 <li>Postconditions: <tt class="docutils literal"><span class="pre">size()</span> <span class="pre">==</span> <span class="pre">0</span></tt></li>
516 </ul>
517 </blockquote>
518 </li>
519 </ul>
520 <!-- - ``reversible_ptr_container( size_type n, const T& x );``
521
522 - Effects: Constructs a container with ``n`` clones of ``x``
523
524 - Postconditions: ``size() == n`` -->
525 <ul>
526 <li><p class="first"><tt class="docutils literal"><span class="pre">explicit</span> <span class="pre">reversible_ptr_container(</span> <span class="pre">const</span> <span class="pre">reversible_ptr_container&amp;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
527 <blockquote>
528 <ul class="simple">
529 <li>Effects: Constructs a container by cloning all elements of <tt class="docutils literal"><span class="pre">r</span></tt></li>
530 </ul>
531 </blockquote>
532 </li>
533 <li><p class="first"><tt class="docutils literal"><span class="pre">template&lt;</span> <span class="pre">class</span> <span class="pre">Derived</span> <span class="pre">&gt;</span> <span class="pre">explicit</span> <span class="pre">reversible_ptr_container(</span> <span class="pre">const</span> <span class="pre">reversible_ptr_container&lt;Derived&gt;&amp;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
534 <blockquote>
535 <ul class="simple">
536 <li>Effects: Constructs a container by cloning all elements of <tt class="docutils literal"><span class="pre">r</span></tt></li>
537 <li>Requirements: <tt class="docutils literal"><span class="pre">Derived</span></tt> is derived from <tt class="docutils literal"><span class="pre">T</span></tt></li>
538 </ul>
539 </blockquote>
540 </li>
541 <li><p class="first"><tt class="docutils literal"><span class="pre">explicit</span> <span class="pre">reversible_ptr_container(</span> <span class="pre">std::auto_ptr&lt;</span> <span class="pre">reversible_ptr_container</span> <span class="pre">&gt;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
542 <blockquote>
543 <ul class="simple">
544 <li>Effects: Constructs a container by taking ownership of the supplied pointers</li>
545 </ul>
546 </blockquote>
547 </li>
548 <li><p class="first"><tt class="docutils literal"><span class="pre">template&lt;</span> <span class="pre">class</span> <span class="pre">InputIterator</span> <span class="pre">&gt;</span></tt>
549 <tt class="docutils literal"><span class="pre">reversible_ptr_container(</span> <span class="pre">InputIterator</span> <span class="pre">first,</span> <span class="pre">InputIterator</span> <span class="pre">last</span> <span class="pre">);</span></tt></p>
550 <blockquote>
551 <ul class="simple">
552 <li>Requirements: <tt class="docutils literal"><span class="pre">(first,last]</span></tt> is a valid range</li>
553 <li>Effects: Constructs a container with a cloned range of <tt class="docutils literal"><span class="pre">(first,last]</span></tt></li>
554 <li>Postconditions: <tt class="docutils literal"><span class="pre">size()</span> <span class="pre">==</span> <span class="pre">std::distance(</span> <span class="pre">first,</span> <span class="pre">last</span> <span class="pre">)</span></tt></li>
555 </ul>
556 </blockquote>
557 </li>
558 <li><p class="first"><tt class="docutils literal"><span class="pre">~reversible_ptr_container();</span></tt></p>
559 <blockquote>
560 <ul class="simple">
561 <li>Effects: Deletes the stored objects via the clone allocator</li>
562 <li>Throws: Nothing</li>
563 </ul>
564 </blockquote>
565 </li>
566 <li><p class="first"><tt class="docutils literal"><span class="pre">reversible_ptr_container&amp;</span> <span class="pre">operator=(</span> <span class="pre">const</span> <span class="pre">reversible_ptr_container&amp;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
567 <blockquote>
568 <ul class="simple">
569 <li>Effects: Assigns a clone of <tt class="docutils literal"><span class="pre">r</span></tt></li>
570 <li>Exception safety: strong guarantee</li>
571 </ul>
572 </blockquote>
573 </li>
574 <li><p class="first"><tt class="docutils literal"><span class="pre">template&lt;class</span> <span class="pre">Derived&gt;</span> <span class="pre">reversible_ptr_container&amp;</span> <span class="pre">operator=(</span> <span class="pre">const</span> <span class="pre">reversible_ptr_container&lt;Derived&gt;&amp;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
575 <blockquote>
576 <ul class="simple">
577 <li>Effects: Assigns a clone of <tt class="docutils literal"><span class="pre">r</span></tt></li>
578 <li>Requirements: <tt class="docutils literal"><span class="pre">Derived</span></tt> is derived from <tt class="docutils literal"><span class="pre">T</span></tt></li>
579 <li>Exception safety: Strong guarantee</li>
580 </ul>
581 </blockquote>
582 </li>
583 <li><p class="first"><tt class="docutils literal"><span class="pre">reversible_ptr_container&amp;</span> <span class="pre">operator=(</span> <span class="pre">std::auto_ptr&lt;reversible_ptr_container&gt;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
584 <blockquote>
585 <ul class="simple">
586 <li>Effects: Deletes the stored objects and then takes ownership of the supplied pointers</li>
587 <li>Throws: Nothing</li>
588 </ul>
589 </blockquote>
590 </li>
591 <li><p class="first"><tt class="docutils literal"><span class="pre">allocator_type</span> <span class="pre">get_allocator()</span> <span class="pre">const;</span></tt></p>
592 <blockquote>
593 <ul class="simple">
594 <li>Effects: Returns a copy of the allocator of the container object</li>
595 </ul>
596 </blockquote>
597 </li>
598 </ul>
599 </div>
600 <div class="section">
601 <h2><a id="semantics-iterators" name="semantics-iterators"><span id="iterators"></span>Semantics: iterators</a></h2>
602 <p><strong>See also:</strong> <a class="reference" href="conventions.html#iterators-are-invalidated-as-in-the-corresponding-standard-container">iterator invalidation</a></p>
603 <ul>
604 <li><p class="first"><tt class="docutils literal"><span class="pre">iterator</span> <span class="pre">begin();</span></tt></p>
605 </li>
606 <li><p class="first"><tt class="docutils literal"><span class="pre">const_iterator</span> <span class="pre">begin()</span> <span class="pre">const;</span></tt></p>
607 <blockquote>
608 <ul class="simple">
609 <li>Effects: Returns a mutable/non-mutable iterator with <tt class="docutils literal"><span class="pre">value_type</span> <span class="pre">T</span></tt></li>
610 <li>Throws: Nothing</li>
611 </ul>
612 </blockquote>
613 </li>
614 <li><p class="first"><tt class="docutils literal"><span class="pre">iterator</span> <span class="pre">end();</span></tt></p>
615 </li>
616 <li><p class="first"><tt class="docutils literal"><span class="pre">const_iterator</span> <span class="pre">end()</span> <span class="pre">const;</span></tt></p>
617 <blockquote>
618 <ul class="simple">
619 <li>Effects: Returns a mutable/non-mutable iterator with <tt class="docutils literal"><span class="pre">value_type</span> <span class="pre">T</span></tt></li>
620 <li>Throws: Nothing</li>
621 </ul>
622 </blockquote>
623 </li>
624 <li><p class="first"><tt class="docutils literal"><span class="pre">reverse_iterator</span> <span class="pre">rbegin();</span></tt></p>
625 </li>
626 <li><p class="first"><tt class="docutils literal"><span class="pre">const_reverse_iterator</span> <span class="pre">rbegin()</span> <span class="pre">const;</span></tt></p>
627 <blockquote>
628 <ul class="simple">
629 <li>Effects: Returns a mutable/non-mutable reverse iterator with <tt class="docutils literal"><span class="pre">value_type</span> <span class="pre">T</span></tt></li>
630 <li>Throws: Nothing</li>
631 </ul>
632 </blockquote>
633 </li>
634 <li><p class="first"><tt class="docutils literal"><span class="pre">reverse_iterator</span> <span class="pre">rend();</span></tt></p>
635 </li>
636 <li><p class="first"><tt class="docutils literal"><span class="pre">const_reverse_iterator</span> <span class="pre">rend()</span> <span class="pre">const;</span></tt></p>
637 <blockquote>
638 <ul class="simple">
639 <li>Effects: Returns a mutable/non-mutable reverse iterator with <tt class="docutils literal"><span class="pre">value_type</span> <span class="pre">T</span></tt></li>
640 <li>Throws: Nothing</li>
641 </ul>
642 </blockquote>
643 </li>
644 </ul>
645 </div>
646 <div class="section">
647 <h2><a id="semantics-capacity" name="semantics-capacity"><span id="capacity"></span>Semantics: capacity</a></h2>
648 <ul>
649 <li><p class="first"><tt class="docutils literal"><span class="pre">size_type</span> <span class="pre">size()</span> <span class="pre">const;</span></tt></p>
650 <blockquote>
651 <ul class="simple">
652 <li>Effects: Returns the number of stored elements</li>
653 <li>Throws: Nothing</li>
654 </ul>
655 </blockquote>
656 </li>
657 <li><p class="first"><tt class="docutils literal"><span class="pre">size_type</span> <span class="pre">max_size()</span> <span class="pre">const;</span></tt></p>
658 <blockquote>
659 <ul class="simple">
660 <li>Effects: Returns the maximum number of stored elements</li>
661 <li>Throws: Nothing</li>
662 </ul>
663 </blockquote>
664 </li>
665 <li><p class="first"><tt class="docutils literal"><span class="pre">bool</span> <span class="pre">empty()</span> <span class="pre">const;</span></tt></p>
666 <blockquote>
667 <ul class="simple">
668 <li>Effects: Returns whether the container is empty or not</li>
669 <li>Throws: Nothing</li>
670 </ul>
671 </blockquote>
672 </li>
673 </ul>
674 </div>
675 <div class="section">
676 <h2><a id="semantics-modifiers" name="semantics-modifiers"><span id="modifiers"></span>Semantics: modifiers</a></h2>
677 <ul>
678 <li><p class="first"><tt class="docutils literal"><span class="pre">void</span> <span class="pre">swap(</span> <span class="pre">reversible_ptr_container&amp;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
679 <blockquote>
680 <ul class="simple">
681 <li>Effects: Swaps the content of the two containers</li>
682 <li>Throws: Nothing</li>
683 </ul>
684 </blockquote>
685 </li>
686 <li><p class="first"><tt class="docutils literal"><span class="pre">void</span> <span class="pre">clear();</span></tt></p>
687 <blockquote>
688 <ul class="simple">
689 <li>Effects: Destroys all object of the container</li>
690 <li>Postconditions: <tt class="docutils literal"><span class="pre">empty()</span> <span class="pre">==</span> <span class="pre">true</span></tt></li>
691 <li>Throws: Nothing</li>
692 </ul>
693 </blockquote>
694 </li>
695 <li><p class="first"><tt class="docutils literal"><span class="pre">VoidPtrContainer&amp;</span> <span class="pre">base();</span></tt></p>
696 </li>
697 <li><p class="first"><tt class="docutils literal"><span class="pre">const</span> <span class="pre">VoidPtrContainer&amp;</span> <span class="pre">base()</span> <span class="pre">const;</span></tt></p>
698 <blockquote>
699 <ul class="simple">
700 <li>Returns: a reference to the wrapped container</li>
701 </ul>
702 </blockquote>
703 </li>
704 </ul>
705 </div>
706 <div class="section">
707 <h2><a id="semantics-pointer-container-requirements" name="semantics-pointer-container-requirements"><span id="pointer-container-requirements"></span>Semantics: pointer container requirements</a></h2>
708 <ul>
709 <li><p class="first"><tt class="docutils literal"><span class="pre">auto_type</span> <span class="pre">replace(</span> <span class="pre">iterator</span> <span class="pre">position,</span> <span class="pre">T*</span> <span class="pre">x</span> <span class="pre">);</span></tt></p>
710 <blockquote>
711 <ul class="simple">
712 <li>Requirements: <tt class="docutils literal"><span class="pre">not</span> <span class="pre">empty()</span> <span class="pre">and</span> <span class="pre">x</span> <span class="pre">!=</span> <span class="pre">0</span></tt></li>
713 <li>Effects: returns the object pointed to by <tt class="docutils literal"><span class="pre">position</span></tt> and replaces it with <tt class="docutils literal"><span class="pre">x</span></tt>.</li>
714 <li>Throws: <tt class="docutils literal"><span class="pre">bad_ptr_container_operation</span></tt> if the container is empty and <tt class="docutils literal"><span class="pre">bad_pointer</span></tt> if <tt class="docutils literal"><span class="pre">x</span> <span class="pre">==</span> <span class="pre">0</span></tt>.</li>
715 <li>Exception safety: Strong guarantee</li>
716 </ul>
717 </blockquote>
718 </li>
719 <li><p class="first"><tt class="docutils literal"><span class="pre">template&lt;</span> <span class="pre">class</span> <span class="pre">U</span> <span class="pre">&gt;</span> <span class="pre">auto_type</span> <span class="pre">replace(</span> <span class="pre">iterator</span> <span class="pre">position,</span> <span class="pre">std::auto_ptr&lt;U&gt;</span> <span class="pre">x</span> <span class="pre">);</span></tt></p>
720 <blockquote>
721 <ul class="simple">
722 <li>Effects: <tt class="docutils literal"><span class="pre">return</span> <span class="pre">replace(</span> <span class="pre">position,</span> <span class="pre">x.release()</span> <span class="pre">);</span></tt></li>
723 </ul>
724 </blockquote>
725 </li>
726 <li><p class="first"><tt class="docutils literal"><span class="pre">std::auto_ptr&lt;</span> <span class="pre">reversible_ptr_container</span> <span class="pre">&gt;</span> <span class="pre">clone()</span> <span class="pre">const;</span></tt></p>
727 <blockquote>
728 <ul class="simple">
729 <li>Effects: Returns a deep copy of the container</li>
730 <li>Throws: <tt class="docutils literal"><span class="pre">std::bad_alloc</span></tt> if there is not enough memory to make a clone of the container</li>
731 <li>Complexity: Linear</li>
732 </ul>
733 </blockquote>
734 </li>
735 <li><p class="first"><tt class="docutils literal"><span class="pre">std::auto_ptr&lt;</span> <span class="pre">reversible_ptr_container</span> <span class="pre">&gt;</span> <span class="pre">release();</span></tt></p>
736 <blockquote>
737 <ul class="simple">
738 <li>Effects: Releases ownership of the container. This is a useful way of returning a container from a function.</li>
739 <li>Postconditions: <tt class="docutils literal"><span class="pre">empty()</span> <span class="pre">==</span> <span class="pre">true</span></tt></li>
740 <li>Throws: <tt class="docutils literal"><span class="pre">std::bad_alloc</span></tt> if the return value cannot be allocated</li>
741 <li>Exception safety: Strong guarantee</li>
742 </ul>
743 </blockquote>
744 </li>
745 <li><p class="first"><tt class="docutils literal"><span class="pre">auto_type</span> <span class="pre">release(</span> <span class="pre">iterator</span> <span class="pre">position</span> <span class="pre">);</span></tt></p>
746 <blockquote>
747 <ul class="simple">
748 <li>Requirements: <tt class="docutils literal"><span class="pre">not</span> <span class="pre">empty();</span></tt></li>
749 <li>Effects: Releases ownership of the pointer referred to by position</li>
750 <li>Postconditions: <tt class="docutils literal"><span class="pre">size()</span></tt> is one less</li>
751 <li>Throws: <tt class="docutils literal"><span class="pre">bad_ptr_container_operation</span></tt> if the container is empty</li>
752 <li>Exception safety: Strong guarantee</li>
753 </ul>
754 </blockquote>
755 </li>
756 </ul>
757 </div>
758 <div class="section">
759 <h2><a id="semantics-comparison" name="semantics-comparison"><span id="comparison"></span>Semantics: comparison</a></h2>
760 <p>These functions compare the underlying range of objects. 
761 So</p>
762 <pre class="literal-block">
763 operation( const ptr_container&amp; l, const ptr_container&amp; r );
764 </pre>
765 <p>has the effect one would expect of normal standard containers. Hence
766 objects are compared and not the pointers to objects.</p>
767 </div>
768 <div class="section">
769 <h2><a id="semantics-cloneability" name="semantics-cloneability"><span id="cloneability"></span>Semantics: cloneability</a></h2>
770 <ul>
771 <li><p class="first"><tt class="docutils literal"><span class="pre">template&lt;</span> <span class="pre">class</span> <span class="pre">T,</span> <span class="pre">class</span> <span class="pre">CloneAllocator</span> <span class="pre">&gt;</span>
772 <span class="pre">reversible_ptr_container&lt;T,CA,VPC&gt;*</span> 
773 <span class="pre">new_clone(</span> <span class="pre">const</span> <span class="pre">reversible_ptr_container&lt;T,CA,VPC&gt;&amp;</span> <span class="pre">r</span> <span class="pre">);</span></tt></p>
774 <blockquote>
775 <ul class="simple">
776 <li>Effects: <tt class="docutils literal"><span class="pre">return</span> <span class="pre">r.clone().release();</span></tt></li>
777 <li>Remarks: This function is only defined for concrete <a class="reference" href="ptr_container.html#smart-containers">pointer containers</a>, but not for 
778 <a class="reference" href="ptr_container.html#smart-container-adapters">pointer container adapters</a>.</li>
779 </ul>
780 </blockquote>
781 </li>
782 </ul>
783 </div>
784 <div class="section">
785 <h2><a id="semantics-null-predicate" name="semantics-null-predicate"><span id="null-predicate"></span>Semantics: null predicate</a></h2>
786 <ul>
787 <li><p class="first"><tt class="docutils literal"><span class="pre">template&lt;</span> <span class="pre">class</span> <span class="pre">Iterator</span> <span class="pre">&gt;</span> <span class="pre">bool</span> <span class="pre">is_null(</span> <span class="pre">Iterator</span> <span class="pre">i</span> <span class="pre">);</span></tt></p>
788 <blockquote>
789 <ul class="simple">
790 <li>Requirements: <tt class="docutils literal"><span class="pre">i</span></tt> is a valid dereferencable iterator</li>
791 <li>Returns: <tt class="docutils literal"><span class="pre">*i.base()</span> <span class="pre">==</span> <span class="pre">0;</span></tt></li>
792 </ul>
793 </blockquote>
794 </li>
795 </ul>
796 </div>
797 <div class="section">
798 <h2><a id="semantics-serialization" name="semantics-serialization"><span id="serialization"></span>Semantics: serialization</a></h2>
799 <p>All containers can be serialized by means of
800 <a class="reference" href="../../serialization/index.html">Boost.Serialization</a>. For an overview, see
801 <a class="reference" href="reference.html#serialization">Serialization of Pointer Containers</a>.</p>
802 <blockquote>
803 <pre class="literal-block">
804 template&lt;class Archive, class T, class CA, class VPC&gt;
805 void serialize( Archive&amp; ar, reversible_ptr_container&lt;T,CA,VPC&gt;&amp; c, const unsigned int version );
806 </pre>
807 </blockquote>
808 <ul class="simple">
809 <li>Effects: Saves or loads the container to/from the archive.</li>
810 <li>Remarks: This function is called automatically be stream operators in
811 Boost.Serialization</li>
812 <li>Exception safety: Loading gives the basic guarantee</li>
813 </ul>
814 <hr><table class="docutils field-list" frame="void" rules="none">
815 <col class="field-name" />
816 <col class="field-body" />
817 <tbody valign="top">
818 <tr class="field"><th class="field-name">Copyright:</th><td class="field-body">Thorsten Ottosen 2004-2007. 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>
819 </tr>
820 </tbody>
821 </table>
822 </div>
823 </div>
824 </div>
825 </body>
826 </html>