ptr_sequence_adapter.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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-ptr-sequence-adapter">
  281. <h1>Class <tt class="docutils literal">ptr_sequence_adapter</tt></h1>
  282. <p>This section describes all the common operations for all the pointer
  283. sequences:</p>
  284. <ul class="simple">
  285. <li><a class="reference external" href="ptr_vector.html">ptr_vector</a></li>
  286. <li><a class="reference external" href="ptr_list.html">ptr_list</a></li>
  287. <li><a class="reference external" href="ptr_deque.html">ptr_deque</a></li>
  288. </ul>
  289. <p>The <tt class="docutils literal">ptr_sequence_adapter</tt> is also a concrete class that you can use to create custom pointer
  290. containers from.</p>
  291. <p><strong>Hierarchy:</strong></p>
  292. <ul class="simple">
  293. <li><a class="reference external" href="reversible_ptr_container.html">reversible_ptr_container</a><ul>
  294. <li><tt class="docutils literal">ptr_sequence_adapter</tt><ul>
  295. <li><a class="reference external" href="ptr_vector.html">ptr_vector</a></li>
  296. <li><a class="reference external" href="ptr_list.html">ptr_list</a></li>
  297. <li><a class="reference external" href="ptr_deque.html">ptr_deque</a></li>
  298. <li><a class="reference external" href="ptr_array.html">ptr_array</a></li>
  299. </ul>
  300. </li>
  301. </ul>
  302. </li>
  303. </ul>
  304. <p><strong>Navigate:</strong></p>
  305. <ul class="simple">
  306. <li><a class="reference external" href="ptr_container.html">home</a></li>
  307. <li><a class="reference external" href="reference.html">reference</a></li>
  308. </ul>
  309. <p><strong>Synopsis:</strong></p>
  310. <pre class="literal-block">
  311. namespace boost
  312. {
  313. template
  314. &lt;
  315. class T,
  316. class VoidPtrSeq,
  317. class CloneAllocator = heap_clone_allocator
  318. &gt;
  319. class ptr_sequence_adapter
  320. {
  321. public: // <a class="reference internal" href="#construct-copy-destroy">construct/copy/destroy</a>
  322. template&lt; class InputIterator &gt;
  323. assign( InputIterator first, InputIterator last );
  324. template&lt; class InputRange &gt;
  325. assign( const InputRange&amp; e );
  326. public: // <a class="reference internal" href="#element-access">element access</a>
  327. T&amp; front();
  328. const T&amp; front() const;
  329. T&amp; back();
  330. const T&amp; back() const;
  331. public: // <a class="reference internal" href="#modifiers">modifiers</a>
  332. void push_back( T* x );
  333. template&lt; class U &gt;
  334. void push_back( <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a>&lt;U&gt; x );
  335. auto_type pop_back();
  336. iterator insert( iterator position, T* x );
  337. template&lt; class U &gt;
  338. iterator insert( iterator position, <a class="reference external" href="compatible_smart_ptr.html"><em>compatible-smart-ptr</em></a>&lt;U&gt; x );
  339. template&lt; class InputIterator &gt;
  340. void insert( iterator position, InputIterator first, InputIterator last );
  341. template&lt; class InputRange &gt;
  342. void insert( iterator position, const InputRange&amp; r );
  343. iterator erase( iterator position );
  344. iterator erase( iterator first, iterator last );
  345. template&lt; class Range &gt;
  346. iterator erase( const Range&amp; r );
  347. void resize( size_type size );
  348. void resize( size_type size, T* to_clone );
  349. public: // <a class="reference internal" href="#pointer-container-requirements">pointer container requirements</a>
  350. template&lt; class PtrSequence &gt;
  351. void transfer( iterator before, typename PtrSequence::iterator object,
  352. PtrSequence&amp; from );
  353. template&lt; class PtrSequence &gt;
  354. void transfer( iterator before, typename PtrSequence::iterator first, typename PtrSequence::iterator last,
  355. PtrSequence&amp; from );
  356. void template&lt; class PtrSequence, class Range &gt;
  357. void transfer( iterator before, const Range&amp; r, PtrSequence&amp; from );
  358. template&lt; class PtrSequence &gt;
  359. void transfer( iterator before, PtrSequence&amp; from );
  360. public: // <a class="reference internal" href="#algorithms">algorithms</a>
  361. void sort();
  362. void sort( iterator first, iterator last );
  363. template&lt; class Compare &gt;
  364. void sort( Compare comp );
  365. template&lt; class Compare &gt;
  366. void sort( iterator begin, iterator end, Compare comp );
  367. void unique();
  368. void unique( iterator first, iterator last );
  369. template&lt; class Compare &gt;
  370. void unique( Compare comp );
  371. template&lt; class Compare &gt;
  372. void unique( iterator begin, iterator end, Compare comp );
  373. template&lt; class Pred &gt;
  374. void erase_if( Pred pred );
  375. template&lt; class Pred &gt;
  376. void erase_if( iterator begin, iterator end, Pred pred );
  377. void merge( ptr_sequence_adapter&amp; r );
  378. template&lt; class Compare &gt;
  379. void merge( ptr_sequence_adapter&amp; r, Compare comp );
  380. void merge( iterator first, iterator last, ptr_sequence_adapter&amp; from );
  381. template&lt; class Compare &gt;
  382. void merge( iterator first, iterator last, ptr_sequence_adapter&amp; from, Compare comp );
  383. public: // <a class="reference external" href="ptr_list.html">ptr_list interface</a>
  384. public: // <a class="reference external" href="ptr_vector.html">ptr_vector interface</a>
  385. public: // <a class="reference external" href="ptr_deque.html">ptr_deque interface</a>
  386. }; // class 'ptr_sequence_adapter'
  387. } // namespace 'boost'
  388. </pre>
  389. </div>
  390. <div class="section" id="semantics">
  391. <h1>Semantics</h1>
  392. <div class="section" id="semantics-construct-copy-destroy">
  393. <span id="construct-copy-destroy"></span><h2>Semantics: construct/copy/destroy</h2>
  394. <ul>
  395. <li><p class="first"><tt class="docutils literal">template&lt; class InputIterator &gt;
  396. void assign( InputIterator first, InputIterator last );</tt></p>
  397. <blockquote>
  398. <ul class="simple">
  399. <li>Requirements: <tt class="docutils literal">(first,last]</tt> is a valid range</li>
  400. <li>Effects: <tt class="docutils literal"><span class="pre">clear();</span> insert( first, last );</tt></li>
  401. <li>Postconditions: <tt class="docutils literal">size() == <span class="pre">std::distance(</span> first, last );</tt></li>
  402. <li>Exception safety: strong guarantee</li>
  403. </ul>
  404. </blockquote>
  405. </li>
  406. <li><p class="first"><tt class="docutils literal">template&lt; class InputRange &gt;
  407. void assign( const InputRange&amp; r );</tt></p>
  408. <blockquote>
  409. <ul class="simple">
  410. <li>Effects: <tt class="docutils literal">assign( <span class="pre">boost::begin(r),</span> <span class="pre">boost::end(r)</span> );</tt></li>
  411. </ul>
  412. </blockquote>
  413. </li>
  414. </ul>
  415. <!-- - ``assign( size_type n, const T& u )``
  416. - Effects: ``clear(); insert( begin(), n, u );``
  417. - Postconditions: ``size() == n``
  418. - Exception safety: Strong guarantee -->
  419. <!-- void resize( size_type sz, const T& x );
  420. Effects:
  421. if ( sz > size() )
  422. insert( end(), sz-size(), x );
  423. else if ( sz < size() )
  424. erase( begin()+sz, end() );
  425. else
  426. ; //do nothing
  427. Postconditions: size() == sz
  428. Exception safety: Strong guarantee -->
  429. </div>
  430. <div class="section" id="semantics-element-access">
  431. <span id="element-access"></span><h2>Semantics: element access</h2>
  432. <ul>
  433. <li><p class="first"><tt class="docutils literal">T&amp; <span class="pre">front();</span></tt></p>
  434. <blockquote>
  435. <ul class="simple">
  436. <li>Requirements: <tt class="docutils literal">not <span class="pre">empty();</span></tt></li>
  437. <li>Effects: <tt class="docutils literal">return <span class="pre">*begin();</span></tt></li>
  438. </ul>
  439. </blockquote>
  440. </li>
  441. <li><p class="first"><tt class="docutils literal">const T&amp; front() const;</tt></p>
  442. <blockquote>
  443. <ul class="simple">
  444. <li>Requirements: <tt class="docutils literal">not <span class="pre">empty();</span></tt></li>
  445. <li>Effects: <tt class="docutils literal">return <span class="pre">*begin();</span></tt></li>
  446. </ul>
  447. </blockquote>
  448. </li>
  449. <li><p class="first"><tt class="docutils literal">T&amp; <span class="pre">back();</span></tt></p>
  450. <blockquote>
  451. <ul class="simple">
  452. <li>Requirements: <tt class="docutils literal">not <span class="pre">empty();</span></tt></li>
  453. <li>Effects: <tt class="docutils literal">return <span class="pre">*--end();</span></tt></li>
  454. </ul>
  455. </blockquote>
  456. </li>
  457. <li><p class="first"><tt class="docutils literal">const T&amp; back() const;</tt></p>
  458. <blockquote>
  459. <ul class="simple">
  460. <li>Requirements: <tt class="docutils literal">not <span class="pre">empty();</span></tt></li>
  461. <li>Effects: <tt class="docutils literal">return <span class="pre">*--end();</span></tt></li>
  462. </ul>
  463. </blockquote>
  464. </li>
  465. </ul>
  466. </div>
  467. <div class="section" id="semantics-modifiers">
  468. <span id="modifiers"></span><h2>Semantics: modifiers</h2>
  469. <ul>
  470. <li><p class="first"><tt class="docutils literal">void push_back( T* x );</tt></p>
  471. <blockquote>
  472. <ul class="simple">
  473. <li>Requirements: <tt class="docutils literal">x != 0</tt></li>
  474. <li>Effects: Inserts the pointer into container and takes ownership of it</li>
  475. <li>Throws: <tt class="docutils literal">bad_pointer</tt> if <tt class="docutils literal">x == 0</tt></li>
  476. <li>Exception safety: Strong guarantee</li>
  477. </ul>
  478. </blockquote>
  479. </li>
  480. <li><p class="first"><tt class="docutils literal">template&lt; class U &gt; void push_back( <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>
  481. <blockquote>
  482. <ul class="simple">
  483. <li>Effects: <tt class="docutils literal">push_back( x.release() );</tt></li>
  484. </ul>
  485. </blockquote>
  486. </li>
  487. </ul>
  488. <!-- - ``void push_back( const T& x );``
  489. - Effects: ``push_back( CloneAllocator::clone( x ) );``
  490. - Exception safety: Strong guarantee -->
  491. <ul>
  492. <li><p class="first"><tt class="docutils literal">auto_type <span class="pre">pop_back();</span></tt></p>
  493. <blockquote>
  494. <ul class="simple">
  495. <li>Requirements:<tt class="docutils literal">not empty()</tt></li>
  496. <li>Effects: Removes the last element in the container</li>
  497. <li>Postconditions: <tt class="docutils literal">size()</tt> is one less</li>
  498. <li>Throws: <tt class="docutils literal">bad_ptr_container_operation</tt> if <tt class="docutils literal">empty() == true</tt></li>
  499. <li>Exception safety: Strong guarantee</li>
  500. </ul>
  501. </blockquote>
  502. </li>
  503. <li><p class="first"><tt class="docutils literal">iterator insert( iterator position, T* x );</tt></p>
  504. <blockquote>
  505. <ul class="simple">
  506. <li>Requirements: <tt class="docutils literal">position</tt> is a valid iterator from the container and
  507. <tt class="docutils literal">x != 0</tt></li>
  508. <li>Effects: Inserts <tt class="docutils literal">x</tt> before <tt class="docutils literal">position</tt> and returns an iterator pointing to it</li>
  509. <li>Throws: <tt class="docutils literal">bad_pointer</tt> if <tt class="docutils literal">x == 0</tt></li>
  510. <li>Exception safety: Strong guarantee</li>
  511. </ul>
  512. </blockquote>
  513. </li>
  514. <li><p class="first"><tt class="docutils literal">template&lt; class U &gt; iterator insert( 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>
  515. <blockquote>
  516. <ul class="simple">
  517. <li>Effects: <tt class="docutils literal">return insert( position, x.release() );</tt></li>
  518. </ul>
  519. </blockquote>
  520. </li>
  521. </ul>
  522. <!-- - ``iterator insert( iterator position, const T& x );``
  523. - Requirements: ``position`` is a valid iterator from the container
  524. - Effects: ``return insert( position, CloneAllocator::clone( x ) );``
  525. - Exception safety: Strong guarantee
  526. - ``void insert( iterator position, size_type n, const T& x );``
  527. - Requirements: ``position`` is a valid iterator from the container
  528. - Effects: Inserts ``n`` clones of ``x`` before position into the container
  529. - Exception safety: Strong guarantee -->
  530. <ul>
  531. <li><p class="first"><tt class="docutils literal">template&lt; class InputIterator &gt;
  532. void insert( iterator position, InputIterator first, InputIterator last );</tt></p>
  533. <blockquote>
  534. <ul class="simple">
  535. <li>Requirements: <tt class="docutils literal">position</tt> is a valid iterator from the container</li>
  536. <li>Effects: Inserts a cloned range before <tt class="docutils literal">position</tt></li>
  537. <li>Exception safety: Strong guarantee</li>
  538. </ul>
  539. </blockquote>
  540. </li>
  541. <li><p class="first"><tt class="docutils literal">template&lt; class InputRange &gt;
  542. void insert( iterator position, const InputRange&amp; r );</tt></p>
  543. <blockquote>
  544. <ul class="simple">
  545. <li>Effects: <tt class="docutils literal">insert( position, <span class="pre">boost::begin(r),</span> <span class="pre">boost::end(r)</span> );</tt></li>
  546. </ul>
  547. </blockquote>
  548. </li>
  549. <li><p class="first"><tt class="docutils literal">iterator erase( iterator position );</tt></p>
  550. <blockquote>
  551. <ul class="simple">
  552. <li>Requirements: <tt class="docutils literal">position</tt> is a valid iterator from the container</li>
  553. <li>Effects: Removes the element defined by <tt class="docutils literal">position</tt> and returns an iterator to the following element</li>
  554. <li>Throws: Nothing</li>
  555. </ul>
  556. </blockquote>
  557. </li>
  558. <li><p class="first"><tt class="docutils literal">iterator erase( iterator first, iterator last );</tt></p>
  559. <blockquote>
  560. <ul class="simple">
  561. <li>Requirements: <tt class="docutils literal">[first,last)</tt> is a valid range</li>
  562. <li>Effects: Removes the range of element defined by <tt class="docutils literal">[first,last)</tt> and returns an iterator to the following element</li>
  563. <li>Throws: Nothing</li>
  564. </ul>
  565. </blockquote>
  566. </li>
  567. <li><p class="first"><tt class="docutils literal">template&lt; class Range &gt;
  568. void erase( const Range&amp; r );</tt></p>
  569. <blockquote>
  570. <ul class="simple">
  571. <li>Effects: <tt class="docutils literal">erase( <span class="pre">boost::begin(r),</span> <span class="pre">boost::end(r)</span> );</tt></li>
  572. </ul>
  573. </blockquote>
  574. </li>
  575. <li><p class="first"><tt class="docutils literal">void resize( size_type size );</tt></p>
  576. <blockquote>
  577. <ul class="simple">
  578. <li>Effects: Resizes the container. If elements are erased, it happens from the back. If elements are inserted, it happens at the back.</li>
  579. <li>Requirements: <tt class="docutils literal">T</tt> is default constructible</li>
  580. <li>Postcondition: <tt class="docutils literal">size() == size;</tt></li>
  581. <li>Exception safety: Basic guarantee under expansion; nothrow guarantee otherwise</li>
  582. </ul>
  583. </blockquote>
  584. </li>
  585. <li><p class="first"><tt class="docutils literal">void resize( size_type size, T* to_clone );</tt></p>
  586. <blockquote>
  587. <ul class="simple">
  588. <li>Effects: Resizes the container. If elements are erased, it happens from the back. If elements are inserted, clones of <tt class="docutils literal">*to_clone</tt> are inserted at the back.</li>
  589. <li>Postcondition: <tt class="docutils literal">size() == size;</tt></li>
  590. <li>Exception safety: Basic guarantee under expansion; nothrow guarantee otherwise</li>
  591. <li>Remarks: <tt class="docutils literal">to_clone == 0</tt> is valid if the container supports nulls. The container does not take ownership of <tt class="docutils literal">to_clone</tt>.</li>
  592. </ul>
  593. </blockquote>
  594. </li>
  595. </ul>
  596. </div>
  597. <div class="section" id="semantics-pointer-container-requirements">
  598. <span id="pointer-container-requirements"></span><h2>Semantics: pointer container requirements</h2>
  599. <p>You can use <tt class="docutils literal">transfer()</tt> to move elements between two containers of the same type. Furthermore,
  600. you can also move elements from a container of type <tt class="docutils literal">T</tt> to a container of type <tt class="docutils literal">U</tt> as long as
  601. <tt class="docutils literal"><span class="pre">T::value_type</span></tt> is convertible to <tt class="docutils literal"><span class="pre">U::value_type</span></tt>. An example would be transferring from <tt class="docutils literal"><span class="pre">boost::ptr_vector&lt;Derived&gt;</span></tt>
  602. to <tt class="docutils literal"><span class="pre">boost::ptr_deque&lt;Base&gt;</span></tt>.</p>
  603. <p>(<strong>Remark:</strong> <em>When moving elements between two different containers, it is your responsibility to make sure the allocators are compatible.</em>
  604. <em>The special latitude of being able to transfer between two different containers is only available for Sequences and not for Associative Containers.</em>)</p>
  605. <!-- -->
  606. <ul>
  607. <li><p class="first"><tt class="docutils literal">template&lt; class PtrSequence &gt; void transfer( iterator before, typename <span class="pre">PtrSequence::iterator</span> object, PtrSequence&amp; from );</tt></p>
  608. <blockquote>
  609. <ul class="simple">
  610. <li>Effects: Inserts the object defined by <tt class="docutils literal">object</tt> into the container and remove it from <tt class="docutils literal">from</tt>.
  611. Insertion takes place before <tt class="docutils literal">before</tt>.</li>
  612. <li>Postconditions: If <tt class="docutils literal">from.empty()</tt>, nothing happens. Otherwise
  613. <tt class="docutils literal">size()</tt> is one more, <tt class="docutils literal">from.size()</tt> is one less.</li>
  614. <li>Exception safety: Strong guarantee</li>
  615. </ul>
  616. </blockquote>
  617. </li>
  618. <li><p class="first"><tt class="docutils literal">template&lt; class PtrSequence &gt; void transfer( iterator before, typename <span class="pre">PtrSequence::iterator</span> first, typename <span class="pre">PtrSequence::iterator</span> last, PtrSequence&amp; from );</tt></p>
  619. <blockquote>
  620. <ul class="simple">
  621. <li>Requirements: <tt class="docutils literal">from.size() &gt;= <span class="pre">std::distance(first,last)</span></tt></li>
  622. <li>Effects: Inserts the objects defined by the range <tt class="docutils literal">[first,last)</tt> into the container and remove it from <tt class="docutils literal">from</tt>.
  623. Insertion takes place before <tt class="docutils literal">before</tt>.</li>
  624. <li>Postconditions: If <tt class="docutils literal">from.empty()</tt>, nothing happens. Otherwise,
  625. let <tt class="docutils literal">N == <span class="pre">std::distance(first,last);</span></tt> then <tt class="docutils literal">size()</tt> is <tt class="docutils literal">N</tt> more, <tt class="docutils literal">from.size()</tt> is <tt class="docutils literal">N</tt> less.</li>
  626. <li>Exception safety: Strong guarantee</li>
  627. <li>Complexity: Linear or better</li>
  628. </ul>
  629. </blockquote>
  630. </li>
  631. <li><p class="first"><tt class="docutils literal">void template&lt; class PtrSequence, class Range &gt; void transfer( iterator before, const Range&amp; r, PtrSequence&amp; from );</tt></p>
  632. <blockquote>
  633. <ul class="simple">
  634. <li>Effects: <tt class="docutils literal">transfer(before, <span class="pre">boost::begin(r),</span> <span class="pre">boost::end(r),</span> from);</tt></li>
  635. </ul>
  636. </blockquote>
  637. </li>
  638. <li><p class="first"><tt class="docutils literal">template&lt; class PtrSequence&gt; void transfer( iterator before, PtrSequence&amp; from );</tt></p>
  639. <blockquote>
  640. <ul class="simple">
  641. <li>Effects: <tt class="docutils literal">transfer(before, from, from);</tt></li>
  642. </ul>
  643. </blockquote>
  644. </li>
  645. </ul>
  646. </div>
  647. <div class="section" id="semantics-algorithms">
  648. <span id="algorithms"></span><h2>Semantics: algorithms</h2>
  649. <p>The general requirement for these algorithms is that the container <em>does not
  650. contain any nulls</em>.</p>
  651. <ul>
  652. <li><p class="first"><tt class="docutils literal">void <span class="pre">sort();</span></tt></p>
  653. </li>
  654. <li><p class="first"><tt class="docutils literal">void sort( iterator first, iterator last );</tt></p>
  655. </li>
  656. <li><p class="first"><tt class="docutils literal">template&lt; class Compare &gt; void sort( Compare comp );</tt></p>
  657. </li>
  658. <li><p class="first"><tt class="docutils literal">template&lt; class Compare &gt; void sort( iterator begin, iterator end, Compare comp );</tt></p>
  659. <blockquote>
  660. <ul class="simple">
  661. <li>Requirements: (versions without <tt class="docutils literal">Compare</tt>) <tt class="docutils literal">bool operator&lt;( const T&amp;, const T&amp; )</tt> is defined</li>
  662. <li>Requirements: (<tt class="docutils literal">Compare</tt> versions) <tt class="docutils literal">Compare</tt> must take <tt class="docutils literal">const T&amp;</tt> arguments</li>
  663. <li>Effects: sorts the entire container or the specified range</li>
  664. <li>Exception safety: nothrow guarantee (the behavior is undefined if the comparison operator throws)</li>
  665. <li>Remarks: The versions of <tt class="docutils literal">sort()</tt> that take two iterators are not available for <tt class="docutils literal">ptr_list</tt></li>
  666. </ul>
  667. </blockquote>
  668. </li>
  669. <li><p class="first"><tt class="docutils literal">void <span class="pre">unique();</span></tt></p>
  670. </li>
  671. <li><p class="first"><tt class="docutils literal">void unique( iterator first, iterator last );</tt></p>
  672. </li>
  673. <li><p class="first"><tt class="docutils literal">template&lt; class Compare &gt; void unique( Compare comp );</tt></p>
  674. </li>
  675. <li><p class="first"><tt class="docutils literal">template&lt; class Compare &gt; void unique( iterator begin, iterator end, Compare comp );</tt></p>
  676. <blockquote>
  677. <ul class="simple">
  678. <li>Requirements: (versions without <tt class="docutils literal">Compare</tt>) <tt class="docutils literal">bool <span class="pre">operator==(</span> const T&amp;, const T&amp; )</tt> is defined</li>
  679. <li>Requirements: (<tt class="docutils literal">Compare</tt> versions) <tt class="docutils literal">Compare</tt> must take <tt class="docutils literal">const T&amp;</tt> arguments</li>
  680. <li>Effects: removes adjacent and equal objects from the entire container or the specified range</li>
  681. <li>Exception safety: nothrow guarantee (the behavior is undefined if the comparison operator throws)</li>
  682. </ul>
  683. </blockquote>
  684. </li>
  685. <li><p class="first"><tt class="docutils literal">template&lt; class Pred &gt; void erase_if( Pred pred );</tt></p>
  686. </li>
  687. <li><p class="first"><tt class="docutils literal">template&lt; class Pred &gt; void erase_if( iterator begin, iterator end, Pred pred );</tt></p>
  688. <blockquote>
  689. <ul class="simple">
  690. <li>Requirements: <tt class="docutils literal">Pred</tt> must take an <tt class="docutils literal">const T&amp;</tt> argument</li>
  691. <li>Effects: removes all elements <tt class="docutils literal">t</tt> for which <tt class="docutils literal">pred(t)</tt> returns <tt class="docutils literal">true</tt> from the entire container or the specified range</li>
  692. <li>Exception safety: nothrow guarantee (the behavior is undefined if the comparison operator throws)</li>
  693. </ul>
  694. </blockquote>
  695. </li>
  696. <li><p class="first"><tt class="docutils literal">void merge( ptr_sequence_adapter&amp; r );</tt></p>
  697. </li>
  698. <li><p class="first"><tt class="docutils literal">template&lt; class Compare &gt; void merge( ptr_sequence_adapter&amp; r, Compare comp );</tt></p>
  699. </li>
  700. <li><p class="first"><tt class="docutils literal">void merge( iterator first, iterator last, ptr_sequence_adapter&amp; from );</tt></p>
  701. </li>
  702. <li><p class="first"><tt class="docutils literal">template&lt; class Compare &gt; void merge( iterator first, iterator last, ptr_sequence_adapter&amp; from, Compare comp );</tt></p>
  703. <blockquote>
  704. <ul class="simple">
  705. <li>Requirements: (<tt class="docutils literal">Compare</tt> versions) <tt class="docutils literal">Compare</tt> must take <tt class="docutils literal">const T&amp;</tt> arguments</li>
  706. <li>Requirements: both sequences are sorted wrt. the same predicate</li>
  707. <li>Effects: transfers the entire container or the specified sequence to the container while
  708. ensuring the new sequence is also sorted</li>
  709. <li>Postconditions: (Container versions) <tt class="docutils literal">r.empty()</tt></li>
  710. <li>Exception safety: nothrow guarantee (the behavior is undefined if the comparison operator throws)</li>
  711. </ul>
  712. </blockquote>
  713. </li>
  714. </ul>
  715. <hr><table class="docutils field-list" frame="void" rules="none">
  716. <col class="field-name" />
  717. <col class="field-body" />
  718. <tbody valign="top">
  719. <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>
  720. </tr>
  721. </tbody>
  722. </table>
  723. </div>
  724. </div>
  725. </div>
  726. </body>
  727. </html>