# push_front

### Synopsis

    template<
          typename Sequence
        , typename T
        >
    struct push_front
    {
        typedef unspecified type;
    };

### Description

`push_front` performs an insertion at the beginning of the sequence. The algorithm returns a new sequence which contains type `T` as its first element. The result sequence preserves all the functional and performance characteristics of the original `Sequence`, except its size and identity.

### Definition

    #include "boost/mpl/push_front.hpp"

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`Sequence` | A model of Extensible Sequence | A sequence to handle the insert operation.
`T` | A type | The element to be inserted.

### Expression semantics

Expression | Expression type | Precondition | Semantics | Postcondition
--- | --- | --- | --- | ---
`typedef push_front<Sequence,T>::type s;` | A model of Extensible Sequence |  | Equivalent to `typedef insert< Sequence,begin<Sequence>::type,T >::type s;` | `size<s>::type::value == size<Sequence>::type::value + 1`; `front<s>::type` is identical to `T`

### Complexity

Amortized constant time [1].

### Example

    typedef list_c<int,1,2,3,5,8,13,21> something;
    BOOST_STATIC_ASSERT(size<something>::type::value == 7);
    typedef push_front< something,integral_c<int,1> >::type fibonacci;
    BOOST_STATIC_ASSERT(size<fibonacci>::type::value == 8);
    BOOST_STATIC_ASSERT((equal< fibonacci,list_c<int,1,1,2,3,5,8,13,21>,equal_to<_,_> >::type::value));

### Notes

[1] The algorithm can be viewed as a notational shorcut to more verbose `insert< Sequence,begin<Sequence>::type,T >::type`, and is provided only if the sequence can meet the stated complexity requirements.

### See also

Extensible Sequence, `insert`, `front`, `pop_front`, `push_back`

Table of Contents
Last edited September 11, 2002 4:27 am