I'm writing a simple program which makes use of std::map::erase
.
The program is fine, but there is something I do not understand.
If I pass to the erase
function an interval in which the first iterator is beyond the second one, the function does not erase anything. And it is good.
On the other side, if I use std::distance
with the first iterator beyond the second one this function "fails". I know that this is due to the nature of the map's iterator, and for example with std::vector
there is not this problem.
But I do not understand how map::erase
could know whether the interval is valid or not.