1.. Sequences/Intrinsic Metafunctions//push_front 2 3push_front 4========== 5 6Synopsis 7-------- 8 9.. parsed-literal:: 10 11 template< 12 typename Sequence 13 , typename T 14 > 15 struct push_front 16 { 17 typedef |unspecified| type; 18 }; 19 20 21 22Description 23----------- 24 25``push_front`` performs an insertion at the beginning of the sequence with guaranteed |O(1)| 26complexity. 27 28 29Header 30------ 31 32.. parsed-literal:: 33 34 #include <boost/mpl/push_front.hpp> 35 36 37Model of 38-------- 39 40|Tag Dispatched Metafunction| 41 42 43Parameters 44---------- 45 46+---------------+-------------------------------+-----------------------------------------------+ 47| Parameter | Requirement | Description | 48+===============+===============================+===============================================+ 49| ``Sequence`` | |Front Extensible Sequence| | A sequence to insert into. | 50+---------------+-------------------------------+-----------------------------------------------+ 51| ``T`` | Any type | The element to be inserted. | 52+---------------+-------------------------------+-----------------------------------------------+ 53 54 55 56Expression semantics 57-------------------- 58 59 60For any |Front Extensible Sequence| ``s`` and arbitrary type ``x``: 61 62 63.. parsed-literal:: 64 65 typedef push_front<s,x>::type r; 66 67:Return type: 68 |Front Extensible Sequence|. 69 70:Semantics: 71 Equivalent to 72 73 .. parsed-literal:: 74 75 typedef insert< s,begin<s>::type,x >::type r; 76 77 78:Postcondition: 79 ``size<r>::value == size<s>::value + 1``; 80 ``front<r>::type`` is identical to ``x``. 81 82 83Complexity 84---------- 85 86Amortized constant time. 87 88 89Example 90------- 91 92.. parsed-literal:: 93 94 typedef vector_c<int,1,2,3,5,8,13,21> v; 95 BOOST_MPL_ASSERT_RELATION( size<v>::value, ==, 7 ); 96 97 typedef push_front< v,integral_c<int,1> >::type fibonacci; 98 BOOST_MPL_ASSERT_RELATION( size<fibonacci>::value, ==, 8 ); 99 100 BOOST_MPL_ASSERT(( equal< 101 fibonacci 102 , vector_c<int,1,1,2,3,5,8,13,21> 103 , equal_to<_,_> 104 > )); 105 106 107See also 108-------- 109 110|Front Extensible Sequence|, |insert|, |pop_front|, |front|, |push_back| 111 112 113.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 114 Distributed under the Boost Software License, Version 1.0. (See accompanying 115 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 116