std::list::insert
STD::列表::插入
| (1) | |
---|---|---|
iterator insert( iterator pos, const T& value | (until C++11) | |
iterator insert( const_iterator pos, const T& value | (since C++11) | |
iterator insert( const_iterator pos, T&& value | (2) | (since C++11) |
| (3) | |
void insert( iterator pos, size_type count, const T& value | (until C++11) | |
iterator insert( const_iterator pos, size_type count, const T& value | (since C++11) | |
| (4) | |
template< class InputIt > void insert( iterator pos, InputIt first, InputIt last | (until C++11) | |
template< class InputIt > iterator insert( const_iterator pos, InputIt first, InputIt last | (since C++11) | |
iterator insert( const_iterator pos, std::initializer_list<T> ilist | (5) | (since C++11) |
在容器中指定的位置插入元素。
1-2%29次插入value
以前pos
3%29次插入count
的副本value
以前pos
4%29插入范围内的元素[first, last)
以前pos
...
This overload has the same effect as overload (3) if InputIt is an integral type. | (until C++11) |
---|---|
This overload only participates in overload resolution if InputIt qualifies as InputIterator, to avoid ambiguity with the overload (3). | (since C++11) |
如果first
和last
迭代器是否进入*this
...
5%29从初始化程序列表插入元素ilist
以前pos
...
没有迭代器或引用无效。
参数
pos | - | iterator before which the content will be inserted. pos may be the end() iterator |
---|---|---|
value | - | element value to insert |
first, last | - | the range of elements to insert, can't be iterators into container for which insert is called |
ilist | - | initializer list to insert the values from |
类型要求
T必须满足CopyInsertable的要求才能使用过载%281%29。
T必须满足MoveInsertable的要求才能使用过载%282%29。
-T必须满足CopyAssignable和CopyInsertable的要求,才能使用过载%283%29。
-T必须符合EmplaceConstrucable的要求,才能使用过载%284,5%29。
返回值
1-2%29字符指向插入的value
3%29 Iterator指向插入的第一个元素,或pos
如果count==0
...
4%29 Iterator指向插入的第一个元素,或pos
如果first==last
...
5%29 Iterator指向插入的第一个元素,或pos
如果ilist
是空的。
复杂性
1-2%29常数。
3%29线性count
4%29线性std::distance
(first, last)
5%29线性ilist.size()
例外
如果抛出异常,则不存在效果%28强异常保证%29。
另见
emplace (C++11) | constructs element in-place (public member function) |
---|---|
push_front | inserts an element to the beginning (public member function) |
push_back | adds an element to the end (public member function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。