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 366<div class="section" id="class-ptr-array"> 367<h1>Class <tt class="docutils literal">ptr_array</tt></h1> 368<p>A <tt class="docutils literal">ptr_array<T,size></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">boost::array<void*,size></span></tt> 369to store the pointers. The class is useful when there is no requirement 370of dynamic expansion and when no overhead is tolerable.</p> 371<p><strong>Hierarchy:</strong></p> 372<ul class="simple"> 373<li><a class="reference external" href="reversible_ptr_container.html">reversible_ptr_container</a><ul> 374<li><a class="reference external" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a><ul> 375<li><a class="reference external" href="ptr_vector.html">ptr_vector</a></li> 376<li><a class="reference external" href="ptr_list.html">ptr_list</a></li> 377<li><a class="reference external" href="ptr_deque.html">ptr_deque</a></li> 378<li><tt class="docutils literal">ptr_array</tt></li> 379</ul> 380</li> 381</ul> 382</li> 383</ul> 384<p><strong>Navigate:</strong></p> 385<ul class="simple"> 386<li><a class="reference external" href="ptr_container.html">home</a></li> 387<li><a class="reference external" href="reference.html">reference</a></li> 388</ul> 389<p><strong>Synopsis:</strong></p> 390<pre class="literal-block"> 391namespace boost 392{ 393 394 template 395 < 396 class T, 397 size_t N, 398 CloneAllocator = heap_clone_allocator 399 > 400 class ptr_array : public <em>implementation-defined</em> 401 { 402 public: // <a class="reference internal" href="#construct-copy-destroy">construct/copy/destroy</a> 403 ptr_array(); 404 explicit ptr_array( const ptr_array& r ); 405 template< class U > 406 explicit ptr_array( const ptr_array<U,N>& r ); 407 explicit ptr_array( <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><ptr_array>& r ); 408 409 ptr_array& operator=( const ptr_array& r ); 410 template< class U > 411 ptr_array& operator=( const ptr_array<U,N>& r ); 412 ptr_array& operator=( <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><this_type> r ); 413 414 public: // <a class="reference external" href="reversible_ptr_container.html#iterators">iterators</a> 415 416 public: // <a class="reference external" href="reversible_ptr_container.html#capacity">capacity</a> 417 418 public: // <a class="reference internal" href="#element-access">element access</a> 419 T& front(); 420 const T& front() const; 421 T& back(); 422 const T& back() const; 423 424 template< size_t idx > 425 T& at(); 426 template< size_t idx > 427 const T& at() const; 428 T& at( size_t ); 429 const T& at( size_t ); 430 431 T& operator[]( size_t ); 432 const T& operator[]( size_t ) const; 433 434 public: // <a class="reference internal" href="#modifiers">modifiers</a> 435 void swap( ptr_array& r ); 436 437 template< size_t idx > 438 auto_type replace( T* r ); 439 template< size_t idx, class U > 440 auto_type replace( <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><U> r ); 441 auto_type replace( size_t idx, T* r ); 442 template< class U > 443 auto_type replace( size_t idx, <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><U> r ); 444 445 public: // <a class="reference internal" href="#pointer-container-requirements">pointer container requirements</a> 446 <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><ptr_array> clone() const; 447 <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><ptr_array> release(); 448 template< size_t idx > 449 bool is_null() const; 450 bool is_null( size_t idx ) const; 451 452 }; // class 'ptr_sequence_adapter' 453 454} // namespace 'boost' 455</pre> 456</div> 457<div class="section" id="semantics"> 458<h1>Semantics</h1> 459<div class="section" id="semantics-construct-copy-destroy"> 460<span id="construct-copy-destroy"></span><h2>Semantics: construct/copy/destroy</h2> 461<ul> 462<li><p class="first"><tt class="docutils literal"><span class="pre">ptr_array();</span></tt></p> 463<blockquote> 464<ul class="simple"> 465<li>Effects: constructs array where each element is null</li> 466</ul> 467</blockquote> 468</li> 469<li><p class="first"><tt class="docutils literal">explicit ptr_array( const ptr_array& r );</tt></p> 470</li> 471<li><p class="first"><tt class="docutils literal">template< class U > 472explicit ptr_array( const ptr_array<U,N>& r );</tt></p> 473<ul class="simple"> 474<li>Effects: Constructs array by cloning <tt class="docutils literal">r</tt></li> 475</ul> 476</li> 477<li><p class="first"><tt class="docutils literal">ptr_array( <span class="pre"><a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><ptr_array>&</span> r );</tt></p> 478<blockquote> 479<ul class="simple"> 480<li>Effects: take ownership of the supplied pointers</li> 481</ul> 482</blockquote> 483</li> 484<li><p class="first"><tt class="docutils literal">ptr_array& operator=( const ptr_array& r );</tt></p> 485</li> 486<li><p class="first"><tt class="docutils literal">template< class U > ptr_array& operator=( const ptr_array<U,N>& r );</tt></p> 487<blockquote> 488<ul class="simple"> 489<li>Effects: Assigns a clone of <tt class="docutils literal">r</tt></li> 490<li>Exception safety: Strong guarantee</li> 491</ul> 492</blockquote> 493</li> 494<li><p class="first"><tt class="docutils literal">ptr_array& operator=( <span class="pre"><a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><this_type></span> r );</tt></p> 495<blockquote> 496<ul class="simple"> 497<li>Effects: take ownership of the supplied pointers</li> 498<li>Throws: Nothing</li> 499</ul> 500</blockquote> 501</li> 502</ul> 503</div> 504<div class="section" id="semantics-element-access"> 505<span id="element-access"></span><h2>Semantics: element access</h2> 506<ul> 507<li><p class="first"><tt class="docutils literal">T& <span class="pre">front();</span></tt></p> 508</li> 509<li><p class="first"><tt class="docutils literal">const T& front() const;</tt></p> 510<blockquote> 511<ul class="simple"> 512<li>Requirements: <tt class="docutils literal">not <span class="pre">empty();</span></tt></li> 513<li>Effects: <tt class="docutils literal">return <span class="pre">*begin();</span></tt></li> 514<li>Throws: <tt class="docutils literal">bad_ptr_container_operation</tt> if <tt class="docutils literal">empty() == true</tt></li> 515</ul> 516</blockquote> 517</li> 518<li><p class="first"><tt class="docutils literal">T& <span class="pre">back();</span></tt></p> 519</li> 520<li><p class="first"><tt class="docutils literal">const T& back() const;</tt></p> 521<blockquote> 522<ul class="simple"> 523<li>Requirements: <tt class="docutils literal">not <span class="pre">empty();</span></tt></li> 524<li>Effects: <tt class="docutils literal">return <span class="pre">*--end();</span></tt></li> 525<li>Throws: <tt class="docutils literal">bad_ptr_container_operation</tt> if <tt class="docutils literal">empty() == true</tt></li> 526</ul> 527</blockquote> 528</li> 529<li><p class="first"><tt class="docutils literal">template< size_t idx > T& at( size_type n );</tt></p> 530</li> 531<li><p class="first"><tt class="docutils literal">template< size_t idx > const T& at( size_type n ) const;</tt></p> 532<blockquote> 533<ul class="simple"> 534<li>Requirements: <tt class="docutils literal">idx < size()</tt> (compile-time enforced)</li> 535<li>Effects: Returns a reference to the <tt class="docutils literal">n</tt>'th element</li> 536<li>Throws: nothing</li> 537</ul> 538</blockquote> 539</li> 540<li><p class="first"><tt class="docutils literal">T& at( size_type n );</tt></p> 541</li> 542<li><p class="first"><tt class="docutils literal">const T& at( size_type n ) const;</tt></p> 543<blockquote> 544<ul class="simple"> 545<li>Requirements: <tt class="docutils literal">n < size()</tt></li> 546<li>Effects: Returns a reference to the <tt class="docutils literal">n</tt>'th element</li> 547<li>Throws: <tt class="docutils literal">bad_index</tt> if <tt class="docutils literal">n >=size()</tt></li> 548</ul> 549</blockquote> 550</li> 551<li><p class="first"><tt class="docutils literal">T& <span class="pre">operator[](</span> size_type n );</tt></p> 552</li> 553<li><p class="first"><tt class="docutils literal">const T& <span class="pre">operator[](</span> size_type n ) const;</tt></p> 554<blockquote> 555<ul class="simple"> 556<li>Requirements: <tt class="docutils literal">n < size()</tt></li> 557<li>Effects: Returns a reference to the <tt class="docutils literal">n</tt>'th element</li> 558<li>Throws: Nothing</li> 559</ul> 560</blockquote> 561</li> 562</ul> 563</div> 564<div class="section" id="semantics-modifiers"> 565<span id="modifiers"></span><h2>Semantics: modifiers</h2> 566<ul> 567<li><p class="first"><tt class="docutils literal">void swap( ptr_array& r );</tt></p> 568<blockquote> 569<ul class="simple"> 570<li>Effects: swaps the two arrays</li> 571<li>Complexity: Linear</li> 572<li>Throws: nothing</li> 573</ul> 574</blockquote> 575</li> 576<li><p class="first"><tt class="docutils literal">template< size_t idx > auto_type replace( T* r );</tt></p> 577<blockquote> 578<ul> 579<li><p class="first">Requirements:</p> 580<blockquote> 581<ul class="simple"> 582<li><tt class="docutils literal">idx < size()</tt> (compile-time enforced)</li> 583<li><tt class="docutils literal">r != 0</tt></li> 584</ul> 585</blockquote> 586</li> 587<li><p class="first">Effects: returns the object indexed by <tt class="docutils literal">idx</tt> and replaces it with <tt class="docutils literal">r</tt>.</p> 588</li> 589<li><p class="first">Throws: <tt class="docutils literal">bad_pointer</tt> if <tt class="docutils literal">x == 0</tt>.</p> 590</li> 591<li><p class="first">Exception safety: Strong guarantee</p> 592</li> 593</ul> 594</blockquote> 595</li> 596<li><p class="first"><tt class="docutils literal">template< size_t idx, class U > auto_type replace( <span class="pre"><a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><U></span> r );</tt></p> 597<blockquote> 598<ul class="simple"> 599<li>Effects: <tt class="docutils literal">return replace<idx>( r.release() );</tt></li> 600</ul> 601</blockquote> 602</li> 603<li><p class="first"><tt class="docutils literal">auto_type replace( size_t idx, T* r );</tt></p> 604<blockquote> 605<ul class="simple"> 606<li>Requirements: `` x != 0 and idx < size()``</li> 607<li>Effects: returns the object indexed by <tt class="docutils literal">idx</tt> and replaces it with <tt class="docutils literal">x</tt>.</li> 608<li>Throws: <tt class="docutils literal">bad_index</tt> if <tt class="docutils literal">idx >= size()</tt> and <tt class="docutils literal">bad_pointer</tt> if <tt class="docutils literal">x == 0</tt>.</li> 609<li>Exception safety: Strong guarantee</li> 610</ul> 611</blockquote> 612</li> 613<li><p class="first"><tt class="docutils literal">template< class U > auto_type replace( size_t idx, <span class="pre"><a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><U></span> r );</tt></p> 614<blockquote> 615<ul class="simple"> 616<li>Effects: <tt class="docutils literal">return replace( idx, r.release() );</tt></li> 617</ul> 618</blockquote> 619</li> 620</ul> 621</div> 622<div class="section" id="semantics-pointer-container-requirements"> 623<span id="pointer-container-requirements"></span><h2>Semantics: pointer container requirements</h2> 624<ul> 625<li><p class="first"><tt class="docutils literal"><span class="pre"><a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><ptr_array></span> clone() const;</tt></p> 626<blockquote> 627<ul class="simple"> 628<li>Effects: Returns a deep copy of the container</li> 629<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> 630<li>Complexity: Linear</li> 631</ul> 632</blockquote> 633</li> 634<li><p class="first"><tt class="docutils literal"><span class="pre"><a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a><ptr_array></span> <span class="pre">release();</span></tt></p> 635<blockquote> 636<ul class="simple"> 637<li>Effects: Releases ownership of the container. This is a useful way of returning a container from a function.</li> 638<li>Postconditions: <tt class="docutils literal">empty() == true</tt> and all pointers are null</li> 639<li>Throws: <tt class="docutils literal"><span class="pre">std::bad_alloc</span></tt> if the return value cannot be allocated</li> 640<li>Exception safety: Strong guarantee</li> 641</ul> 642</blockquote> 643</li> 644<li><p class="first"><tt class="docutils literal">template< size_t idx > bool is_null() const;</tt></p> 645<blockquote> 646<ul class="simple"> 647<li>Requirements: <tt class="docutils literal">idx < size()</tt> (compile-time enforced)</li> 648<li>Effects: returns whether the pointer at index <tt class="docutils literal">idx</tt> is null</li> 649<li>Exception safety: Nothrow guarantee</li> 650</ul> 651</blockquote> 652</li> 653<li><p class="first"><tt class="docutils literal">bool is_null( size_type idx ) const;</tt></p> 654<blockquote> 655<ul class="simple"> 656<li>Requirements: <tt class="docutils literal">idx < size()</tt></li> 657<li>Effects: returns whether the pointer at index <tt class="docutils literal">idx</tt> is null</li> 658<li>Exception safety: Nothrow guarantee</li> 659</ul> 660</blockquote> 661</li> 662</ul> 663<hr><table class="docutils field-list" frame="void" rules="none"> 664<col class="field-name" /> 665<col class="field-body" /> 666<tbody valign="top"> 667<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> 668</tr> 669</tbody> 670</table> 671</div> 672</div> 673</div> 674</body> 675</html> 676