Z
Zachary Turner
std::map<int, int> test;
bool eq1 = false;
bool eq2 = false;
test[5] = 7;
std::map<int, int>::iterator iter = test.begin();
std::map<int, int>::iterator iterEnd = test.end();
eq1 = (iter == iterEnd);
--iter;
eq2 = (iter == iterEnd);
I suspect the answer is that no, decrementing the begin iterator is
undefined, but just looking for confirmation. In Visual C++, after
this code executes eq1 is false and eq2 is true(!), and in fact in
Visual C++ you can decrement this iterator indefinitely and it will
just cycle through the tree forever.
bool eq1 = false;
bool eq2 = false;
test[5] = 7;
std::map<int, int>::iterator iter = test.begin();
std::map<int, int>::iterator iterEnd = test.end();
eq1 = (iter == iterEnd);
--iter;
eq2 = (iter == iterEnd);
I suspect the answer is that no, decrementing the begin iterator is
undefined, but just looking for confirmation. In Visual C++, after
this code executes eq1 is false and eq2 is true(!), and in fact in
Visual C++ you can decrement this iterator indefinitely and it will
just cycle through the tree forever.