object::erase
Erase an element.
Synopsis
object::iterator
erase(
object::const_iterator pos) noexcept; (1)
std::size_t
erase(
string_view key) noexcept; (2)
Description
Remove the element pointed to by pos
, which must be valid and dereferenceable. References and iterators to the erased element are invalidated. Other iterators and references are not invalidated.
The end()
iterator (which is valid but cannot be dereferenced) cannot be used as a value for pos
.
Complexity
Constant on average, worst case linear in size()
.
Exception Safety
No-throw guarantee.
Return Value
An iterator following the removed element.
Return Value
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. |