命名空间
变体
操作

std::list<T,Allocator>::emplace_front

来自 cppreference.cn
< cpp‎ | 容器‎ | list
 
 
 
 
template< class... Args >
void emplace_front( Args&&... args );
(C++11 起)
(C++17 前)
template< class... Args >
reference emplace_front( Args&&... args );
(C++17 起)

在容器的开头插入一个新元素。该元素通过 std::allocator_traits::construct 构造,该函数通常使用 placement-new 在容器提供的位置原地构造元素。参数 args... 作为 std::forward<Args>(args)... 转发给构造函数。

迭代器或引用均未失效。

目录

[编辑] 参数

args - 转发给元素构造函数的参数
类型要求
-
T (容器的元素类型) 必须满足 EmplaceConstructible 的要求。

[编辑] 返回值

(无) (C++17 前)
对插入元素的引用。 (C++17 起)

[编辑] 复杂度

常数时间。

[编辑] 异常

如果由于任何原因抛出异常,此函数无效果(强异常安全保证)。

[编辑] 参阅

插入元素到起始
(public member function) [编辑]