插入元素构造就地到列表中的指定位置。
void emplace_back(
iterator _Where,
Type&& _Val
);
参数
Parameter |
说明 |
_Where |
在插入第一个元素的目标 list Class 的位置。 |
_Val |
元素添加到 list的末尾。 |
备注
如果引发了异常,list 未更改,并且异常来重新引发。
示例
// list_emplace.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
#include <string>
int main( )
{
using namespace std;
list <string> c2;
string str("a");
c2.emplace(c2.begin(), move( str ) );
cout << "Moved first element: " << c2.back( ) << endl;
}
要求
标头: <list>
命名空间: std