My app crashed on this operation:
std::multimap<int, std::string, std::greater<int>> mm;
// insert elements
auto it = mm.end();
std::advance(it, -(mm.size() - 7));
Here is the message of crash:
Expression: map/set iterator not incrementable
What is the problem?
EDIT:
When I wrote just -1 instead of -(mm.size() - 7)
it did not crash, why? Please consider that when I debug mm.size() is 8.
EDIT 2:
When I write std::advance(it, -(static_cast<int>(scoresMap.size()) - 7));
it works. It is because of the size type of the multimap, but still cannot guess what is the reason.