Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an STL map iterator go out of bounds through incrementing?

Tags:

For associative containers, can the ++ operator send an iterator past the end of a collection?

Example:

map<UINT32, UINT32> new_map;
new_map[0] = 0;
new_map[1] = 1;

map<UINT32, UINT32> new_iter = new_map.begin();

++new_iter;
++new_iter;
++new_iter;
++new_iter;
++new_iter;
++new_iter;
++new_iter;

At the end of this, does new_iter == new_map.end(), or does it end up in the great unknown?

Note: I know this is messed up and not the way to do things. I'm working around some WTF corporate code.