Skip to main content
Removed suggestion to post on SO.
Source Link
pacmaninbw
  • 26.2k
  • 13
  • 47
  • 114

You should've asked this on stackoverflow instead of codereview. But theThe answer is "yes" it is UB. To fix it just rewrite the part as:

if(it->second==0) { it = _m.erase(it); } else { it++; } 

You should've asked this on stackoverflow instead of codereview. But the answer is "yes" it is UB. To fix it just rewrite the part as:

if(it->second==0) { it = _m.erase(it); } else { it++; } 

The answer is "yes" it is UB. To fix it just rewrite the part as:

if(it->second==0) { it = _m.erase(it); } else { it++; } 
Source Link
ALX23z
  • 2.5k
  • 7
  • 15

You should've asked this on stackoverflow instead of codereview. But the answer is "yes" it is UB. To fix it just rewrite the part as:

if(it->second==0) { it = _m.erase(it); } else { it++; }