| 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 | <!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost --> |
|---|
| 5 | <!-- Software License, Version 1.0. (See accompanying --> |
|---|
| 6 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
|---|
| 7 | <head> |
|---|
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 9 | <meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" /> |
|---|
| 10 | <title>The MPL Reference Manual: erase</title> |
|---|
| 11 | <link rel="stylesheet" href="../style.css" type="text/css" /> |
|---|
| 12 | </head> |
|---|
| 13 | <body class="docframe refmanual"> |
|---|
| 14 | <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./end.html" class="navigation-link">Prev</a> <a href="./erase-key.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./end.html" class="navigation-link">Back</a> <a href="./erase-key.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./intrinsic-metafunctions.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 15 | <td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./erase.html" class="navigation-link">erase</a></td> |
|---|
| 16 | </tr></table><div class="header-separator"></div> |
|---|
| 17 | <div class="section" id="erase"> |
|---|
| 18 | <h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id360" name="erase">erase</a></h1> |
|---|
| 19 | <div class="section" id="erase-synopsis"> |
|---|
| 20 | <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> |
|---|
| 21 | <pre class="literal-block"> |
|---|
| 22 | template< |
|---|
| 23 | typename Sequence |
|---|
| 24 | , typename First |
|---|
| 25 | , typename Last = <em>unspecified</em> |
|---|
| 26 | > |
|---|
| 27 | struct <a href="./erase.html" class="identifier">erase</a> |
|---|
| 28 | { |
|---|
| 29 | typedef <em>unspecified</em> type; |
|---|
| 30 | }; |
|---|
| 31 | </pre> |
|---|
| 32 | </div> |
|---|
| 33 | <div class="section" id="erase-description"> |
|---|
| 34 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
|---|
| 35 | <p><tt class="literal"><span class="pre"><a href="./erase.html" class="identifier">erase</a></span></tt> performs a removal of one or more adjacent elements in the sequence |
|---|
| 36 | starting from an arbitrary position.</p> |
|---|
| 37 | </div> |
|---|
| 38 | <div class="section" id="erase-header"> |
|---|
| 39 | <h3><a class="subsection-title" href="#header" name="header">Header</a></h3> |
|---|
| 40 | <pre class="literal-block"> |
|---|
| 41 | #include <<a href="../../../../boost/mpl/erase.hpp" class="header">boost/mpl/erase.hpp</a>> |
|---|
| 42 | </pre> |
|---|
| 43 | </div> |
|---|
| 44 | <div class="section" id="erase-model-of"> |
|---|
| 45 | <h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3> |
|---|
| 46 | <p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p> |
|---|
| 47 | </div> |
|---|
| 48 | <div class="section" id="erase-parameters"> |
|---|
| 49 | <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> |
|---|
| 50 | <table border="1" class="table"> |
|---|
| 51 | <colgroup> |
|---|
| 52 | <col width="15%" /> |
|---|
| 53 | <col width="36%" /> |
|---|
| 54 | <col width="48%" /> |
|---|
| 55 | </colgroup> |
|---|
| 56 | <thead valign="bottom"> |
|---|
| 57 | <tr><th>Parameter</th> |
|---|
| 58 | <th>Requirement</th> |
|---|
| 59 | <th>Description</th> |
|---|
| 60 | </tr> |
|---|
| 61 | </thead> |
|---|
| 62 | <tbody valign="top"> |
|---|
| 63 | <tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td> |
|---|
| 64 | <td><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> or |
|---|
| 65 | <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a></td> |
|---|
| 66 | <td>A sequence to erase from.</td> |
|---|
| 67 | </tr> |
|---|
| 68 | <tr><td><tt class="literal"><span class="pre">First</span></tt></td> |
|---|
| 69 | <td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td> |
|---|
| 70 | <td>An iterator to the beginning of the range to |
|---|
| 71 | be erased.</td> |
|---|
| 72 | </tr> |
|---|
| 73 | <tr><td><tt class="literal"><span class="pre">Last</span></tt></td> |
|---|
| 74 | <td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td> |
|---|
| 75 | <td>An iterator past-the-end of the range to be |
|---|
| 76 | erased.</td> |
|---|
| 77 | </tr> |
|---|
| 78 | </tbody> |
|---|
| 79 | </table> |
|---|
| 80 | </div> |
|---|
| 81 | <div class="section" id="erase-expression-semantics"> |
|---|
| 82 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
|---|
| 83 | <div class="expression-semantics compound"> |
|---|
| 84 | <p class="compound-first">For any <a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and iterators <tt class="literal"><span class="pre">pos</span></tt>, <tt class="literal"><span class="pre">first</span></tt> and <tt class="literal"><span class="pre">last</span></tt> into <tt class="literal"><span class="pre">s</span></tt>:</p> |
|---|
| 85 | <pre class="compound-middle literal-block"> |
|---|
| 86 | typedef <a href="./erase.html" class="identifier">erase</a><s,first,last>::type r; |
|---|
| 87 | </pre> |
|---|
| 88 | <table class="compound-middle field-list" frame="void" rules="none"> |
|---|
| 89 | <col class="field-name" /> |
|---|
| 90 | <col class="field-body" /> |
|---|
| 91 | <tbody valign="top"> |
|---|
| 92 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>.</td> |
|---|
| 93 | </tr> |
|---|
| 94 | <tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">[first,last)</span></tt> is a valid range in <tt class="literal"><span class="pre">s</span></tt>.</td> |
|---|
| 95 | </tr> |
|---|
| 96 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">r</span></tt> is a new sequence, <a class="reference" href="./terminology.html#concept-identical">concept-identical</a> to <tt class="literal"><span class="pre">s</span></tt>, of the following elements: |
|---|
| 97 | [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a><s>::type</span></tt>, <tt class="literal"><span class="pre">pos</span></tt>), [<tt class="literal"><span class="pre">last</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a><s>::type</span></tt>).</td> |
|---|
| 98 | </tr> |
|---|
| 99 | <tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><p class="first">The relative order of the elements in <tt class="literal"><span class="pre">r</span></tt> is the same as in <tt class="literal"><span class="pre">s</span></tt>;</p> |
|---|
| 100 | <pre class="last literal-block"> |
|---|
| 101 | <a href="./size.html" class="identifier">size</a><r>::value == <a href="./size.html" class="identifier">size</a><s>::value - <a href="./distance.html" class="identifier">distance</a><first,last>::value |
|---|
| 102 | </pre> |
|---|
| 103 | </td> |
|---|
| 104 | </tr> |
|---|
| 105 | </tbody> |
|---|
| 106 | </table> |
|---|
| 107 | <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> |
|---|
| 108 | <pre class="compound-middle literal-block"> |
|---|
| 109 | typedef <a href="./erase.html" class="identifier">erase</a><s,pos>::type r; |
|---|
| 110 | </pre> |
|---|
| 111 | <table class="compound-last field-list" frame="void" rules="none"> |
|---|
| 112 | <col class="field-name" /> |
|---|
| 113 | <col class="field-body" /> |
|---|
| 114 | <tbody valign="top"> |
|---|
| 115 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>.</td> |
|---|
| 116 | </tr> |
|---|
| 117 | <tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">pos</span></tt> is a dereferenceable iterator in <tt class="literal"><span class="pre">s</span></tt>.</td> |
|---|
| 118 | </tr> |
|---|
| 119 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> |
|---|
| 120 | <pre class="last literal-block"> |
|---|
| 121 | typedef <a href="./erase.html" class="identifier">erase</a>< s,pos,<a href="./next.html" class="identifier">next</a><pos>::type >::type r; |
|---|
| 122 | </pre> |
|---|
| 123 | </td> |
|---|
| 124 | </tr> |
|---|
| 125 | </tbody> |
|---|
| 126 | </table> |
|---|
| 127 | </div> |
|---|
| 128 | <div class="expression-semantics compound"> |
|---|
| 129 | <p class="compound-first">For any <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and iterator <tt class="literal"><span class="pre">pos</span></tt> into <tt class="literal"><span class="pre">s</span></tt>:</p> |
|---|
| 130 | <pre class="compound-middle literal-block"> |
|---|
| 131 | typedef <a href="./erase.html" class="identifier">erase</a><s,pos>::type r; |
|---|
| 132 | </pre> |
|---|
| 133 | <table class="compound-last field-list" frame="void" rules="none"> |
|---|
| 134 | <col class="field-name" /> |
|---|
| 135 | <col class="field-body" /> |
|---|
| 136 | <tbody valign="top"> |
|---|
| 137 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>.</td> |
|---|
| 138 | </tr> |
|---|
| 139 | <tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">pos</span></tt> is a dereferenceable iterator to <tt class="literal"><span class="pre">s</span></tt>.</td> |
|---|
| 140 | </tr> |
|---|
| 141 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body">Erases the element at a specific position <tt class="literal"><span class="pre">pos</span></tt>; equivalent to |
|---|
| 142 | <tt class="literal"><span class="pre"><a href="./erase-key.html" class="identifier">erase_key</a><s,</span> <span class="pre"><a href="./deref.html" class="identifier">deref</a><pos>::type</span> <span class="pre">>::type</span></tt>.</td> |
|---|
| 143 | </tr> |
|---|
| 144 | <tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a><r>::value</span> <span class="pre">==</span> <span class="pre"><a href="./size.html" class="identifier">size</a><s>::value</span> <span class="pre">-</span> <span class="pre">1</span></tt>.</td> |
|---|
| 145 | </tr> |
|---|
| 146 | </tbody> |
|---|
| 147 | </table> |
|---|
| 148 | </div> |
|---|
| 149 | </div> |
|---|
| 150 | <div class="section" id="erase-complexity"> |
|---|
| 151 | <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3> |
|---|
| 152 | <table border="1" class="table"> |
|---|
| 153 | <colgroup> |
|---|
| 154 | <col width="45%" /> |
|---|
| 155 | <col width="55%" /> |
|---|
| 156 | </colgroup> |
|---|
| 157 | <thead valign="bottom"> |
|---|
| 158 | <tr><th>Sequence archetype</th> |
|---|
| 159 | <th>Complexity (the range form)</th> |
|---|
| 160 | </tr> |
|---|
| 161 | </thead> |
|---|
| 162 | <tbody valign="top"> |
|---|
| 163 | <tr><td><a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a></td> |
|---|
| 164 | <td>Amortized constant time.</td> |
|---|
| 165 | </tr> |
|---|
| 166 | <tr><td><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a></td> |
|---|
| 167 | <td>Quadratic in the worst case, linear at best.</td> |
|---|
| 168 | </tr> |
|---|
| 169 | </tbody> |
|---|
| 170 | </table> |
|---|
| 171 | </div> |
|---|
| 172 | <div class="section" id="erase-example"> |
|---|
| 173 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
|---|
| 174 | <pre class="literal-block"> |
|---|
| 175 | typedef <a href="./vector-c.html" class="identifier">vector_c</a><int,1,0,5,1,7,5,0,5> values; |
|---|
| 176 | typedef <a href="./find.html" class="identifier">find</a>< values, <a href="./integral-c.html" class="identifier">integral_c</a><int,7> >::type pos; |
|---|
| 177 | typedef <a href="./erase.html" class="identifier">erase</a><values,pos>::type result; |
|---|
| 178 | |
|---|
| 179 | <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a><result>::value, ==, 7 ); |
|---|
| 180 | |
|---|
| 181 | typedef <a href="./find.html" class="identifier">find</a><result, <a href="./integral-c.html" class="identifier">integral_c</a><int,7> >::type iter; |
|---|
| 182 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same< iter, <a href="./end.html" class="identifier">end</a><result>::type > )); |
|---|
| 183 | </pre> |
|---|
| 184 | </div> |
|---|
| 185 | <div class="section" id="erase-see-also"> |
|---|
| 186 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
|---|
| 187 | <p><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>, <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>, <a class="refentry reference" href="./erase-key.html"><tt class="refentry literal"><span class="pre">erase_key</span></tt></a>, <a class="refentry reference" href="./pop-front.html"><tt class="refentry literal"><span class="pre">pop_front</span></tt></a>, <a class="refentry reference" href="./pop-back.html"><tt class="refentry literal"><span class="pre">pop_back</span></tt></a>, <a class="refentry reference" href="./insert.html"><tt class="refentry literal"><span class="pre">insert</span></tt></a></p> |
|---|
| 188 | <!-- modtime: November 10, 2004 04:42:36 +0000 --> |
|---|
| 189 | <!-- Sequences/Intrinsic Metafunctions//erase_key --> |
|---|
| 190 | </div> |
|---|
| 191 | </div> |
|---|
| 192 | |
|---|
| 193 | <div class="footer-separator"></div> |
|---|
| 194 | <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./end.html" class="navigation-link">Prev</a> <a href="./erase-key.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./end.html" class="navigation-link">Back</a> <a href="./erase-key.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./intrinsic-metafunctions.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 195 | </tr></table></body> |
|---|
| 196 | </html> |
|---|