The C ++ 11 erase()standard changed the signature of standard container methods : now they accept const_iteratorinstead of iterators. The rationale is explained in this document:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2350.pdf
Now, if one implements in a std::vector<T>simple way, you can use iterator types directly const T *and T *as const and mutable, respectively. Therefore, in the method erase()we may have the following code:
iterator erase(const_iterator it)
{
...
for (; it != end() - 1; ++it) {
it->~T();
::new (static_cast<void *>(it)) T(std::move(*(it + 1)));
}
...
}
Now the problem is that since it itis a pointer to const, static rollback will fail.
it? , it const (, , const) (erase()) const.
EDIT: . .
( std::vector), . - , , , .
void * - .