deque::emplace_front
添加构造的元素就地 deque 到的末尾。
void emplace_front(
Type&&_Val
);
参数
参数 |
说明 |
_Val |
将元素添加到的开头。deque 类 |
示例
// deque_emplace_front.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>
int main( )
{
using namespace std;
deque <int> v1;
v1.push_back( 1 );
if ( v1.size( ) != 0 )
cout << "Last element: " << v1.back( ) << endl;
v1.push_back( 2 );
if ( v1.size( ) != 0 )
cout << "New last element: " << v1.back( ) << endl;
// initialize a deque of deques by moving v1
deque < deque <int> > vv1;
vv1.emplace_front( move( v1 ) );
if ( vv1.size( ) != 0 && vv1[0].size( ) != 0 )
cout << "Moved last element: " << vv1[0].back( ) << endl;
}
要求
标头: <deque>
命名空间: std