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">
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">
11 :Author: David Goodger
12 :Contact: goodger@users.sourceforge.net
15 :Copyright: This stylesheet has been placed in the public domain.
17 Default cascading style sheet for the HTML output of Docutils.
19 See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
20 customize this style sheet.
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 */
27 margin-top:
0 ! important }
29 .last, .with-subtitle {
30 margin-bottom:
0 ! important }
36 text-decoration: none ;
43 margin-bottom:
0.5em }
45 /* Uncomment (and remove this text!) to get bold-faced definition list terms
53 div.abstract p.topic-title {
57 div.admonition, div.attention, div.caution, div.danger, div.error,
58 div.hint, div.important, div.note, div.tip, div.warning {
60 border: medium outset ;
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 {
67 font-family: sans-serif }
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 {
74 font-family: sans-serif }
76 /* Uncomment (and remove this text!) to get reduced vertical space in
78 div.compound .compound-first, div.compound .compound-middle {
79 margin-bottom:
0.5em }
81 div.compound .compound-last, div.compound .compound-middle {
90 div.dedication p.topic-title {
97 div.footer, div.header {
106 div.line-block div.line-block {
113 border: medium outset ;
115 background-color: #ffffee ;
120 div.sidebar p.rubric {
121 font-family: sans-serif ;
124 div.system-messages {
127 div.system-messages h1 {
131 border: medium outset ;
134 div.system-message p.system-message-title {
141 h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
142 h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
163 ol.simple, ul.simple {
167 list-style: decimal }
170 list-style: lower-alpha }
173 list-style: upper-alpha }
176 list-style: lower-roman }
179 list-style: upper-roman }
193 white-space: nowrap }
202 font-family: sans-serif ;
207 font-family: sans-serif ;
223 pre.literal-block, pre.doctest-block {
226 background-color: #eeeeee }
229 font-family: sans-serif ;
230 font-style: oblique }
232 span.classifier-delimiter {
233 font-family: sans-serif ;
237 font-family: sans-serif }
240 white-space: nowrap }
248 span.section-subtitle {
249 /* font-size relative to parent (h1..h6 element) */
253 border-left: solid thin gray }
260 margin-bottom:
0.5em }
263 border-left: solid thin black }
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 }
271 table.docutils th.field-name, table.docinfo th.docinfo-name {
274 white-space: nowrap ;
277 h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
278 h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
282 background-color: #eeeeee }
285 list-style-type: none }
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-ptr-array" name=
"class-ptr-array">Class
<tt class=
"docutils literal"><span class=
"pre">ptr_array
</span></tt></a></h1>
294 <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>
295 to store the pointers. The class is useful when there is no requirement
296 of dynamic expansion and when no overhead is tolerable.
</p>
297 <p><strong>Hierarchy:
</strong></p>
299 <li><a class=
"reference" href=
"reversible_ptr_container.html">reversible_ptr_container
</a><ul>
300 <li><a class=
"reference" href=
"ptr_sequence_adapter.html">ptr_sequence_adapter
</a><ul>
301 <li><a class=
"reference" href=
"ptr_vector.html">ptr_vector
</a></li>
302 <li><a class=
"reference" href=
"ptr_list.html">ptr_list
</a></li>
303 <li><a class=
"reference" href=
"ptr_deque.html">ptr_deque
</a></li>
304 <li><tt class=
"docutils literal"><span class=
"pre">ptr_array
</span></tt></li>
310 <p><strong>Navigate:
</strong></p>
312 <li><a class=
"reference" href=
"ptr_container.html">home
</a></li>
313 <li><a class=
"reference" href=
"reference.html">reference
</a></li>
315 <p><strong>Synopsis:
</strong></p>
316 <pre class=
"literal-block">
324 CloneAllocator = heap_clone_allocator
326 class ptr_array : public
<em>implementation-defined
</em>
328 public: //
<a class=
"reference" href=
"#construct-copy-destroy">construct/copy/destroy
</a>
330 explicit ptr_array( const ptr_array
& r );
331 template
< class U
>
332 explicit ptr_array( const ptr_array
<U,N
>& r );
333 explicit ptr_array( std::auto_ptr
<ptr_array
>& r );
335 ptr_array
& operator=( const ptr_array
& r );
336 template
< class U
>
337 ptr_array
& operator=( const ptr_array
<U,N
>& r );
338 ptr_array
& operator=( std::auto_ptr
<this_type
> r );
340 public: //
<a class=
"reference" href=
"reversible_ptr_container.html#iterators">iterators
</a>
342 public: //
<a class=
"reference" href=
"reversible_ptr_container.html#capacity">capacity
</a>
344 public: //
<a class=
"reference" href=
"#element-access">element access
</a>
346 const T
& front() const;
348 const T
& back() const;
350 template
< size_t idx
>
352 template
< size_t idx
>
353 const T
& at() const;
355 const T
& at( size_t );
357 T
& operator[]( size_t );
358 const T
& operator[]( size_t ) const;
360 public: //
<a class=
"reference" href=
"#modifiers">modifiers
</a>
361 void swap( ptr_array
& r );
363 template
< size_t idx
>
364 auto_type replace( T* r );
365 template
< size_t idx, class U
>
366 auto_type replace( std::auto_ptr
<U
> r );
367 auto_type replace( size_t idx, T* r );
368 template
< class U
>
369 auto_type replace( size_t idx, std::auto_ptr
<U
> r );
371 public: //
<a class=
"reference" href=
"#pointer-container-requirements">pointer container requirements
</a>
372 std::auto_ptr
<ptr_array
> clone() const;
373 std::auto_ptr
<ptr_array
> release();
374 template
< size_t idx
>
375 bool is_null() const;
376 bool is_null( size_t idx ) const;
378 }; // class 'ptr_sequence_adapter'
380 } // namespace 'boost'
383 <div class=
"section">
384 <h1><a id=
"semantics" name=
"semantics">Semantics
</a></h1>
385 <div class=
"section">
386 <h2><a id=
"semantics-construct-copy-destroy" name=
"semantics-construct-copy-destroy"><span id=
"construct-copy-destroy"></span>Semantics: construct/copy/destroy
</a></h2>
388 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">ptr_array();
</span></tt></p>
391 <li>Effects: constructs array where each element is null
</li>
395 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">explicit
</span> <span class=
"pre">ptr_array(
</span> <span class=
"pre">const
</span> <span class=
"pre">ptr_array
&</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
397 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">class
</span> <span class=
"pre">U
</span> <span class=
"pre">></span>
398 <span class=
"pre">explicit
</span> <span class=
"pre">ptr_array(
</span> <span class=
"pre">const
</span> <span class=
"pre">ptr_array
<U,N
>&</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
400 <li>Effects: Constructs array by cloning
<tt class=
"docutils literal"><span class=
"pre">r
</span></tt></li>
403 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">ptr_array(
</span> <span class=
"pre">std::auto_ptr
<ptr_array
>&</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
406 <li>Effects: take ownership of the supplied pointers
</li>
410 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">ptr_array
&</span> <span class=
"pre">operator=(
</span> <span class=
"pre">const
</span> <span class=
"pre">ptr_array
&</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
412 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">class
</span> <span class=
"pre">U
</span> <span class=
"pre">></span> <span class=
"pre">ptr_array
&</span> <span class=
"pre">operator=(
</span> <span class=
"pre">const
</span> <span class=
"pre">ptr_array
<U,N
>&</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
415 <li>Effects: Assigns a clone of
<tt class=
"docutils literal"><span class=
"pre">r
</span></tt></li>
416 <li>Exception safety: Strong guarantee
</li>
420 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">ptr_array
&</span> <span class=
"pre">operator=(
</span> <span class=
"pre">std::auto_ptr
<this_type
></span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
423 <li>Effects: take ownership of the supplied pointers
</li>
424 <li>Throws: Nothing
</li>
430 <div class=
"section">
431 <h2><a id=
"semantics-element-access" name=
"semantics-element-access"><span id=
"element-access"></span>Semantics: element access
</a></h2>
433 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">T
&</span> <span class=
"pre">front();
</span></tt></p>
435 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">const
</span> <span class=
"pre">T
&</span> <span class=
"pre">front()
</span> <span class=
"pre">const;
</span></tt></p>
438 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">not
</span> <span class=
"pre">empty();
</span></tt></li>
439 <li>Effects:
<tt class=
"docutils literal"><span class=
"pre">return
</span> <span class=
"pre">*begin();
</span></tt></li>
440 <li>Throws:
<tt class=
"docutils literal"><span class=
"pre">bad_ptr_container_operation
</span></tt> if
<tt class=
"docutils literal"><span class=
"pre">empty()
</span> <span class=
"pre">==
</span> <span class=
"pre">true
</span></tt></li>
444 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">T
&</span> <span class=
"pre">back();
</span></tt></p>
446 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">const
</span> <span class=
"pre">T
&</span> <span class=
"pre">back()
</span> <span class=
"pre">const;
</span></tt></p>
449 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">not
</span> <span class=
"pre">empty();
</span></tt></li>
450 <li>Effects:
<tt class=
"docutils literal"><span class=
"pre">return
</span> <span class=
"pre">*--end();
</span></tt></li>
451 <li>Throws:
<tt class=
"docutils literal"><span class=
"pre">bad_ptr_container_operation
</span></tt> if
<tt class=
"docutils literal"><span class=
"pre">empty()
</span> <span class=
"pre">==
</span> <span class=
"pre">true
</span></tt></li>
455 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">size_t
</span> <span class=
"pre">idx
</span> <span class=
"pre">></span> <span class=
"pre">T
&</span> <span class=
"pre">at(
</span> <span class=
"pre">size_type
</span> <span class=
"pre">n
</span> <span class=
"pre">);
</span></tt></p>
457 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">size_t
</span> <span class=
"pre">idx
</span> <span class=
"pre">></span> <span class=
"pre">const
</span> <span class=
"pre">T
&</span> <span class=
"pre">at(
</span> <span class=
"pre">size_type
</span> <span class=
"pre">n
</span> <span class=
"pre">)
</span> <span class=
"pre">const;
</span></tt></p>
460 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">idx
</span> <span class=
"pre"><</span> <span class=
"pre">size()
</span></tt> (compile-time enforced)
</li>
461 <li>Effects: Returns a reference to the
<tt class=
"docutils literal"><span class=
"pre">n
</span></tt>'th element
</li>
462 <li>Throws: nothing
</li>
466 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">T
&</span> <span class=
"pre">at(
</span> <span class=
"pre">size_type
</span> <span class=
"pre">n
</span> <span class=
"pre">);
</span></tt></p>
468 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">const
</span> <span class=
"pre">T
&</span> <span class=
"pre">at(
</span> <span class=
"pre">size_type
</span> <span class=
"pre">n
</span> <span class=
"pre">)
</span> <span class=
"pre">const;
</span></tt></p>
471 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">n
</span> <span class=
"pre"><</span> <span class=
"pre">size()
</span></tt></li>
472 <li>Effects: Returns a reference to the
<tt class=
"docutils literal"><span class=
"pre">n
</span></tt>'th element
</li>
473 <li>Throws:
<tt class=
"docutils literal"><span class=
"pre">bad_index
</span></tt> if
<tt class=
"docutils literal"><span class=
"pre">n
</span> <span class=
"pre">>=size()
</span></tt></li>
477 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">T
&</span> <span class=
"pre">operator[](
</span> <span class=
"pre">size_type
</span> <span class=
"pre">n
</span> <span class=
"pre">);
</span></tt></p>
479 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">const
</span> <span class=
"pre">T
&</span> <span class=
"pre">operator[](
</span> <span class=
"pre">size_type
</span> <span class=
"pre">n
</span> <span class=
"pre">)
</span> <span class=
"pre">const;
</span></tt></p>
482 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">n
</span> <span class=
"pre"><</span> <span class=
"pre">size()
</span></tt></li>
483 <li>Effects: Returns a reference to the
<tt class=
"docutils literal"><span class=
"pre">n
</span></tt>'th element
</li>
484 <li>Throws: Nothing
</li>
490 <div class=
"section">
491 <h2><a id=
"semantics-modifiers" name=
"semantics-modifiers"><span id=
"modifiers"></span>Semantics: modifiers
</a></h2>
493 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">void
</span> <span class=
"pre">swap(
</span> <span class=
"pre">ptr_array
&</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
496 <li>Effects: swaps the two arrays
</li>
497 <li>Complexity: Linear
</li>
498 <li>Throws: nothing
</li>
502 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">size_t
</span> <span class=
"pre">idx
</span> <span class=
"pre">></span> <span class=
"pre">auto_type
</span> <span class=
"pre">replace(
</span> <span class=
"pre">T*
</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
505 <li><p class=
"first">Requirements:
</p>
508 <li><tt class=
"docutils literal"><span class=
"pre">idx
</span> <span class=
"pre"><</span> <span class=
"pre">size()
</span></tt> (compile-time enforced)
</li>
509 <li><tt class=
"docutils literal"><span class=
"pre">r
</span> <span class=
"pre">!=
</span> <span class=
"pre">0</span></tt></li>
513 <li><p class=
"first">Effects: returns the object indexed by
<tt class=
"docutils literal"><span class=
"pre">idx
</span></tt> and replaces it with
<tt class=
"docutils literal"><span class=
"pre">r
</span></tt>.
</p>
515 <li><p class=
"first">Throws:
<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>.
</p>
517 <li><p class=
"first">Exception safety: Strong guarantee
</p>
522 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">size_t
</span> <span class=
"pre">idx,
</span> <span class=
"pre">class
</span> <span class=
"pre">U
</span> <span class=
"pre">></span> <span class=
"pre">auto_type
</span> <span class=
"pre">replace(
</span> <span class=
"pre">std::auto_ptr
<U
></span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
525 <li>Effects:
<tt class=
"docutils literal"><span class=
"pre">return
</span> <span class=
"pre">replace
<idx
>(
</span> <span class=
"pre">r.release()
</span> <span class=
"pre">);
</span></tt></li>
529 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">auto_type
</span> <span class=
"pre">replace(
</span> <span class=
"pre">size_t
</span> <span class=
"pre">idx,
</span> <span class=
"pre">T*
</span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
532 <li>Requirements: `` x !=
0 and idx
< size()``
</li>
533 <li>Effects: returns the object indexed by
<tt class=
"docutils literal"><span class=
"pre">idx
</span></tt> and replaces it with
<tt class=
"docutils literal"><span class=
"pre">x
</span></tt>.
</li>
534 <li>Throws:
<tt class=
"docutils literal"><span class=
"pre">bad_index
</span></tt> if
<tt class=
"docutils literal"><span class=
"pre">idx
</span> <span class=
"pre">>=
</span> <span class=
"pre">size()
</span></tt> 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>
535 <li>Exception safety: Strong guarantee
</li>
539 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">class
</span> <span class=
"pre">U
</span> <span class=
"pre">></span> <span class=
"pre">auto_type
</span> <span class=
"pre">replace(
</span> <span class=
"pre">size_t
</span> <span class=
"pre">idx,
</span> <span class=
"pre">std::auto_ptr
<U
></span> <span class=
"pre">r
</span> <span class=
"pre">);
</span></tt></p>
542 <li>Effects:
<tt class=
"docutils literal"><span class=
"pre">return
</span> <span class=
"pre">replace(
</span> <span class=
"pre">idx,
</span> <span class=
"pre">r.release()
</span> <span class=
"pre">);
</span></tt></li>
548 <div class=
"section">
549 <h2><a id=
"semantics-pointer-container-requirements" name=
"semantics-pointer-container-requirements"><span id=
"pointer-container-requirements"></span>Semantics: pointer container requirements
</a></h2>
551 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">std::auto_ptr
<ptr_array
></span> <span class=
"pre">clone()
</span> <span class=
"pre">const;
</span></tt></p>
554 <li>Effects: Returns a deep copy of the container
</li>
555 <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>
556 <li>Complexity: Linear
</li>
560 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">std::auto_ptr
<ptr_array
></span> <span class=
"pre">release();
</span></tt></p>
563 <li>Effects: Releases ownership of the container. This is a useful way of returning a container from a function.
</li>
564 <li>Postconditions:
<tt class=
"docutils literal"><span class=
"pre">empty()
</span> <span class=
"pre">==
</span> <span class=
"pre">true
</span></tt> and all pointers are null
</li>
565 <li>Throws:
<tt class=
"docutils literal"><span class=
"pre">std::bad_alloc
</span></tt> if the return value cannot be allocated
</li>
566 <li>Exception safety: Strong guarantee
</li>
570 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">size_t
</span> <span class=
"pre">idx
</span> <span class=
"pre">></span> <span class=
"pre">bool
</span> <span class=
"pre">is_null()
</span> <span class=
"pre">const;
</span></tt></p>
573 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">idx
</span> <span class=
"pre"><</span> <span class=
"pre">size()
</span></tt> (compile-time enforced)
</li>
574 <li>Effects: returns whether the pointer at index
<tt class=
"docutils literal"><span class=
"pre">idx
</span></tt> is null
</li>
575 <li>Exception safety: Nothrow guarantee
</li>
579 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">bool
</span> <span class=
"pre">is_null(
</span> <span class=
"pre">size_type
</span> <span class=
"pre">idx
</span> <span class=
"pre">)
</span> <span class=
"pre">const;
</span></tt></p>
582 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">idx
</span> <span class=
"pre"><</span> <span class=
"pre">size()
</span></tt></li>
583 <li>Effects: returns whether the pointer at index
<tt class=
"docutils literal"><span class=
"pre">idx
</span></tt> is null
</li>
584 <li>Exception safety: Nothrow guarantee
</li>
589 <hr><table class=
"docutils field-list" frame=
"void" rules=
"none">
590 <col class=
"field-name" />
591 <col class=
"field-body" />
593 <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" href=
"http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt
</a>).
</td>