首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::list::emplace

template< class... Args > iterator emplace( const_iterator pos, Args&&... args );

(since C++11)

将新元素直接插入容器中。pos元素是通过std::allocator_traits::construct,它通常使用Plant-New来在容器提供的位置构造就地元素。争论args...被转发给构造函数的std::forward<Args>(args)......

没有迭代器或引用无效。

参数

pos

-

iterator before which the new element will be constructed

args

-

arguments to forward to the constructor of the element

类型要求

-T%28容器%27s元素类型%29必须满足EmplaceConstrucable的要求。

返回值

指向放置元素的Iterator。

复杂性

常量。

例外

如果抛出异常%28例如。通过构造函数%29,容器未被修改,就好像该函数从未被调用过%28强异常保证%29一样。

另见

insert

inserts elements (public member function)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券