when and how are iterators invalidated in a map when using the erase method ?
for example :
std :: map < int , int > aMap ;
aMap [ 33 ] = 1 ;
aMap [ 42 ] = 10000 ;
aMap [ 69 ] = 100 ;
aMap [ 666 ] = -1 ;
std :: map < int , int > :: iterator itEnd = aMap.lower_bound ( 50 ) ;
for ( std :: map < int , int > :: iterator it = aMap.begin ( ) ;
it != itEnd ;
// no-op
)
{
aMap.erase ( it ++ ) ;
}
the erased iterator will surely become invalid (it's incremented while still valid) but what about the others?
if I'm not wrong the standard says that a map has to be a balanced binary tree or a structure with equivalent key-search complexity
in case the map is implemented with a tree, can I assume that not erased iterators remain valid ?
what about other possible ways to implement a map ?