reversible_ptr_container.html 32 KB

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