I had to delete some of the entries from c++ std::map
, for that purpose I iterate over the std::map
and used erase. But I get an error. The error is like :
0x0017f3f6 in std::_Rb_tree_rebalance_for_erase () from /usr/local/lib/libstdc++.so.6
(gdb) bt
#0 0x0017f3f6 in std::_Rb_tree_rebalance_for_erase () from /usr/local/lib/libstdc++.so.6
#1 0x00487ef4 in getLetters () from /usr/lib/libmail.so
#2 0x0048cacc in getHeader () from /usr/lib/libmail.so
#6 0x08048802 in __gxx_personality_v0 ()
#7 0x00251e9c in __libc_start_main () from /lib/libc.so.6
#8 0x080486a1 in __gxx_personality_v0 ()
(gdb)
The code was something like this:
int nlsize=LettersMap.size();
if(nlsize > MAXNL)
{
std::map <std::string,MSG_HEADER>::iterator it;
int i=0;
for( i=0, it=LettersMap.begin(); i <nlsize-MAXNL ;i++, it++)
{
LettersMap.erase(it);
}
}
Can someone please point out the error