deque::push_back
将元素添加到 deque 的末尾。
void push_back(
const Type& _Val
);
void push_back(
Type&& _Val
);
参数
参数 |
说明 |
_Val |
将元素添加到 deque 的末尾。 |
备注
如果引发异常,deque 未更改,而异常是异常。
代码示例
// deque_push_back.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>
int main( )
{
using namespace std;
deque <int> d;
d.push_back( 1 );
d.push_back( 2 );
d.push_back( 3 );
for( deque<int>::const_iterator i = d.begin(); i != d.end(); ++i )
{
cout << *i << " ";
}
cout << endl;
d.push_front( 0 );
d.push_back( 4 );
for( deque<int>::const_iterator i = d.begin(); i != d.end(); ++i )
{
cout << *i << " ";
}
cout << endl;
// move initialize a deque of deques by moving d
deque < deque <int> > dd;
dd.push_back( move( d ) );
cout << "Moved last element: " << dd[0].back( ) << endl;
}
Output
1 2 3
0 1 2 3 4
Moved last element: 4
要求
标头: <deque>
命名空间: std