mirror of
https://github.com/boostorg/mpl.git
synced 2026-01-26 17:02:20 +01:00
64 lines
3.3 KiB
HTML
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<
|
|
typename Sequence
|
|
, typename T
|
|
>
|
|
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> Parameter </th><th> Requirement </th><th> Description </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> Expression </th><th> Expression type </th><th> Precondition </th><th> Semantics </th><th> Postcondition </th></tr>
|
|
<tr><td><code>typedef push_front<Sequence,T>::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< Sequence,begin<Sequence>::type,T >::type s;</code></td><td><code>size<s>::type::value == size<Sequence>::type::value + 1</code>; <code>front<s>::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><int,1,2,3,5,8,13,21> something;
|
|
BOOST_STATIC_ASSERT(<a href="../Reference/size.html">size</a><something>::type::value == 7);
|
|
typedef <a href="../Reference/push_front.html">push_front</a>< something,integral_c<int,1> >::type fibonacci;
|
|
BOOST_STATIC_ASSERT(size<fibonacci>::type::value == 8);
|
|
BOOST_STATIC_ASSERT((<a href="../Reference/equal.html">equal</a>< fibonacci,list_c<int,1,1,2,3,5,8,13,21>,equal_to<_,_> >::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< Sequence,begin<Sequence>::type,T >::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> |