The most popular post on C++ Iterator invalidation rules claims that it\'s not clear if the past-the-end iterators (i.e., those returned by end(), cend()<
end()
cend()<
At least in GCC end iterator gets invalidated for std::map:
#include #include #include int main() { std::set a; a.insert(1); std::set::reverse_iterator rit(a.rbegin()); ++rit; assert(rit==a.rend()); a.erase(a.begin()); assert(a.rend()==rit); // FAIL }