std::vector::emplace
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| template< class... Args > iterator emplace( const_iterator pos, Args&&... args ); |
(C++11 起) | |
插入一个新的元素到容器之前,直接
pos。该元件是构成在就地,即没有复制或移动操作进行。元素的构造函数调用的参数std::forward<Args>(args)...。元素类型必须是EmplaceConstructible, MoveInsertable and MoveAssignable.Original:
Inserts a new element into the container directly before
pos. The element is constructed in-place, i.e. no copy or move operations are performed. The constructor of the element is called with the arguments std::forward<Args>(args).... The element type must be EmplaceConstructible, MoveInsertable and MoveAssignable.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references after the added element are invalidated.
目录 |
[编辑] 参数
| pos | - | 迭代器之前,将兴建新的元素
Original: iterator before which the new element will be constructed The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| args | - | 元素的构造函数的参数转发
Original: arguments to forward to the constructor of the element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 返回值
布设元素的迭代器,指向.
Original:
Iterator pointing to the emplaced element.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 复杂性
Linear in the distance between pos and end of the container.
[编辑] 例外
如果抛出一个异常(例如,通过构造函数),容器保持不变,如果这个功能是永远不会被调用(强异常保证).
Original:
If an exception is thrown (e.g. by the constructor), the container is left unmodified, as if this function was never called (strong exception guarantee).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 另请参阅
| 插入元素 Original: inserts elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |