Files
mpl/doc/ref/Reference/erase.html
Aleksey Gurtovoy a69baa5eae update the docs
[SVN r17836]
2003-03-12 13:29:12 +00:00

65 lines
4.4 KiB
HTML

<!doctype html public "-//ietf//dtd html//en">
<html><head><title>boost::mpl::erase</title>
<link rel="stylesheet" href="../mpl_wiki.css">
</head><body bgcolor="white">
<h1><a href="../Table_of_Contents.html"><img src="../mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>erase</h1><h3>Synopsis</h3>
<p>
<pre>
template&lt;
typename Sequence
, typename First
, typename Last = typename First::next
&gt;
struct erase
{
typedef <em>unspecified</em> type;
};
</pre>
<p>
<h3>Description</h3>
<p>
<code>erase</code> performs a removal of one or several consequent elements in the sequence starting from an arbitrary position. The algorithm returns a new sequence which contains all the elements in the ranges <code>[begin&lt;Sequence&gt;::type, First)</code> and <code>[Last, end&lt;Sequence&gt;::type)</code>. The result sequence preserves all the functional and performance characteristics of the original <code>Sequence</code>, except its size and identity.
<p>
<h3>Definition</h3>
<p>
<pre>
#include "<a href="../../../../../boost/mpl/erase.hpp">boost/mpl/erase.hpp</a>"
</pre>
<p>
<h3>Parameters</h3>
<table border="1">
<tr><th>&nbsp;Parameter&nbsp;</th><th>&nbsp;Requirement&nbsp;</th><th>&nbsp;Description&nbsp;</th><th>&nbsp;Default value &nbsp;</th></tr>
<tr><td><code>Sequence</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td>A sequence to handle the erase operation.</td><td></td></tr>
<tr><td><code>First</code></td><td>A model of <a href="../Forward_Iterator.html">Forward Iterator</a></td><td>Iterator to the beginning of the range to be erased.</td><td></td></tr>
<tr><td><code>Last</code></td><td>A model of <a href="../Forward_Iterator.html">Forward Iterator</a></td><td>Past-the-end iterator of the range to be erased.</td><td><code>typename First::next</code> </td></tr>
</table>
<p>
<h3>Expression semantics</h3>
<p>
<table border="1">
<tr><th>&nbsp;Expression&nbsp;</th><th>&nbsp;Expression type&nbsp;</th><th>&nbsp;Precondition&nbsp;</th><th>&nbsp;Semantics&nbsp;</th><th>&nbsp;Postcondition&nbsp;</th></tr>
<tr><td><code>typedef erase&lt;Sequence,pos&gt;::type s;</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td><code>pos</code> is a dereferenceable iterator in <code>Sequence</code>.</td><td>Returns a new sequence which contains all the elements in the ranges <code>[begin&lt;Sequence&gt;::type, pos)</code> and <code>[next&lt;pos&gt;::type, end&lt;Sequence&gt;::type)</code>.</td><td><code>size&lt;s&gt;::type::value == size&lt;Sequence&gt;::type::value - 1</code>; the relative order of the elements in <code>s</code> is the same as in <code>Sequence</code>. </td></tr>
<tr><td><code>typedef erase&lt;Sequence,first,last&gt;::type s;</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td><code>[first,last)</code> is a valid range in <code>Sequence</code>.</td><td>Returns a new sequence which contains all the elements in the ranges <code>[begin&lt;Sequence&gt;::type, first)</code> and <code>[last, end&lt;Sequence&gt;::type)</code>.</td><td><code>size&lt;s&gt;::type::value == size&lt;Sequence&gt;::type::value - distance&lt;first,last&gt;::type::value</code>; the relative order of the elements in <code>s</code> is the same as in <code>Sequence</code>. </td></tr>
</table>
<p>
<h3>Complexity</h3>
<p>
The range form has linear complexity. The complexity of single-element erase is sequence dependent (linear in the worst case, or amortized constant time).
<p>
<h3>Example</h3>
<p>
<pre>
typedef <a href="../Reference/list_c.html">list_c</a>&lt;int,1,0,5,1,7,5,0,5&gt; values;
typedef <a href="../Reference/find.html">find</a>&lt; values, integral_c&lt;int,7&gt; &gt;::type pos;
typedef erase&lt;values,pos&gt;::type result_seq;
BOOST_STATIC_ASSERT(<a href="../Reference/size.html">size</a>&lt;result_seq&gt;::type::value == 7);
<p>
typedef find&lt;result, integral_c&lt;int,7&gt; &gt;::type result_iter;
BOOST_MPL_ASSERT_IS_SAME(result_iter, <a href="../Reference/end.html">end</a>&lt;result_seq&gt;::type);
</pre>
<p>
<h3>See also</h3>
<p>
<a href="../Extensible_Sequence.html">Extensible Sequence</a>, <code><a href="../Reference/pop_front.html">pop_front</a></code>, <code><a href="../Reference/pop_back.html">pop_back</a></code>, <code><a href="../Reference/insert.html">insert</a></code>
<p><hr>
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited July 17, 2002 3:59 am</body></html>