What should std::map iterator decrement return, if there's only single element in the map? Here's the sample code
#include <map>
#include <stdio.h>
int main()
{
std::map<int, int> m;
m.insert(std::make_pair(1, 1));
//std::map<int, int>::iterator it = m.begin();
std::map<int, int>::iterator it = m.upper_bound(0);
printf("isbegin: %d\n", it == m.begin());
--it;
bool isend = it == m.end();
printf("isend: %d\n", isend);
}
On Windows it will print isend: 1, on Linux with g++ 4.6 it will print isend: 0.
The question: is the decrement above really a case of UB? and if not then what result is correct - Windows or Linux one?
UPDATE: modified code to show that upper_bound is called