For example:
std::list <int> list1 = {1, 2, 3, 4, 5};
auto first = list1.begin();
std::cout << std::distance(--first, ++first);
The output is 0. Strange enough, if we change --first
to first--
, the output becomes 5 (although here it should be 0, as it returns first
). What am I missing?