原文如下:(摘自<<c++ standard library>>)
7.2.6 The Increment and Decrement Problem of Vector Iterators
The use of the increment and decrement operators of iterators includes a strange problem. In general, you can increment and decrement temporary iterators. However, for vectors and strings, you typically can't. Consider the following vector example:
std::vector<int> coll; ... //sort, starting with the second element // - NONPORTABLE version if (coll.size() > 1) { coll.sort (++coll.begin(), coll.end()); }
Typically, the compilation of sort() fails. However, if you use, for example, a deque rather than a vector, it will compile. It might compile even with vectors, depending on the implementation of class vector.
The reason for this strange problem lie