Namespaces
Variants

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

From cppreference.net

template < class ... Args >
void emplace_front ( Args && ... args ) ;
(自 C++11 起)
(直至 C++17)
template < class ... Args >
reference emplace_front ( Args && ... args ) ;
(自 C++17 起)
(自 C++26 起为 constexpr)

在容器起始位置插入新元素。该元素通过 std::allocator_traits::construct 构造,通常使用原位构造的 new 操作在容器提供的位置构造元素。参数 args... 会以 std:: forward < Args > ( args ) ... 形式转发给构造函数。

不会使任何迭代器或引用失效。

目录

参数

args - 要转发给元素构造函数的参数
类型要求
-
如果 T 不能通过 args... list 中实现 EmplaceConstructible ,则行为未定义。

返回值

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

复杂度

常量。

异常

若因任何原因抛出异常,此函数不产生任何效果( 强异常安全保证 )。

参见

在开头插入元素
(公开成员函数)