object::erase
Remove an element.
Synopsis
object::iterator
erase(
object::const_iterator pos) noexcept; (1)
std::size_t
erase(
string_view key) noexcept; (2)
Description
-
(1) the element at
pos
is removed. -
(2) the element with the key
key
is removed, if it exists.
pos
must be valid and dereferenceable. References and iterators to the erased element are invalidated. Other iterators and references are not invalidated.
The |
Complexity
Constant on average, worst case linear in size()
.
Exception Safety
No-throw guarantee.
Return Value
-
(1) an iterator following the removed element.
-
(2) the number of elements removed, which will be either 0 or 1.
Parameters
Name | Description |
---|---|
|
An iterator pointing to the element to be removed. |
|
The key to match. |