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

std::unordered_set::emplace_hint

template <class... Args> iterator emplace_hint( const_iterator hint, Args&&... args );

(since C++11)

将新元素插入容器,使用hint作为元素应该去哪里的建议。元素是就地构造的,即不执行复制或移动操作。

元素的构造函数使用与提供给函数的完全相同的参数调用,这些参数由std::forward<Args>(args)......

如果由于插入而发生重散列,则所有迭代器都将失效。否则迭代器不会受到影响。引用不失效。只有当新元素数大于max_load_factor()*bucket_count()...

参数

hint

-

iterator, used as a suggestion as to where to insert the new element

args

-

arguments to forward to the constructor of the element

返回值

将迭代器返回到新插入的元素。

如果插入失败是因为元素已经存在,则将迭代器返回给具有等效键的现有元素。

例外

如果任何操作引发异常,则此函数不具有%28强异常保证%29的效果。

复杂性

平均摊还常数,最坏情况是容器的大小呈线性。

另见

emplace

constructs element in-place (public member function)

insert

inserts elements or nodes (since C++17) (public member function)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券