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

64 lines
3.3 KiB
HTML

<!doctype html public "-//ietf//dtd html//en">
<html><head><title>boost::mpl::push_front</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>push_front</h1><h3>Synopsis</h3>
<p>
<pre>
template&lt;
typename Sequence
, typename T
&gt;
struct push_front
{
typedef <em>unspecified</em> type;
};
</pre>
<p>
<h3>Description</h3>
<p>
<code>push_front</code> performs an insertion at the beginning of the sequence. The algorithm returns a new sequence which contains type <code>T</code> as its first element. 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/push_front.hpp">boost/mpl/push_front.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></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 insert operation. </td></tr>
<tr><td><code>T</code></td><td>A type</td><td>The element to be inserted. </td></tr>
</table>
<p>
<h3>Expression semantics</h3>
<p>
<table border="1">
<tr><th>&nbsp;Expression&nbsp;</th><th>&nbsp;Expression&nbsp;type&nbsp;</th><th>&nbsp;Precondition&nbsp;</th><th>&nbsp;Semantics&nbsp;</th><th>&nbsp;Postcondition&nbsp;</th></tr>
<tr><td><code>typedef push_front&lt;Sequence,T&gt;::type s;</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td></td><td>Equivalent to <code>typedef insert&lt; Sequence,begin&lt;Sequence&gt;::type,T &gt;::type s;</code></td><td><code>size&lt;s&gt;::type::value == size&lt;Sequence&gt;::type::value + 1</code>; <code>front&lt;s&gt;::type</code> is identical to <code>T</code> </td></tr>
</table>
<p>
<h3>Complexity</h3>
<p>
Amortized constant time [<a href="#1">1</a>].
<p>
<h3>Example</h3>
<p>
<pre>
typedef <a href="../Reference/list_c.html">list_c</a>&lt;int,1,2,3,5,8,13,21&gt; something;
BOOST_STATIC_ASSERT(<a href="../Reference/size.html">size</a>&lt;something&gt;::type::value == 7);
typedef <a href="../Reference/push_front.html">push_front</a>&lt; something,integral_c&lt;int,1&gt; &gt;::type fibonacci;
BOOST_STATIC_ASSERT(size&lt;fibonacci&gt;::type::value == 8);
BOOST_STATIC_ASSERT((<a href="../Reference/equal.html">equal</a>&lt; fibonacci,list_c&lt;int,1,1,2,3,5,8,13,21&gt;,equal_to&lt;_,_&gt; &gt;::type::value));
</pre>
<p>
<h3>Notes</h3>
<p>
[<a name="1">1</a>] The algorithm can be viewed as a notational shorcut to more verbose <code>insert&lt; Sequence,begin&lt;Sequence&gt;::type,T &gt;::type</code>, and is provided only if the sequence can meet the stated complexity requirements.<br>
<p>
<h3>See also</h3>
<p>
<a href="../Extensible_Sequence.html">Extensible Sequence</a>, <code><a href="../Reference/insert.html">insert</a></code>, <code><a href="../Reference/front.html">front</a></code>, <code><a href="../Reference/pop_front.html">pop_front</a></code>, <code><a href="../Reference/push_back.html">push_back</a></code>
<p><hr>
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited September 11, 2002 4:27 am</body></html>