...
In this noncompliant code example, iterators from different containers are passed for the same iterator range. Although many STL implementations will compile this code and exhibit reasonable behaviorthe program may behave as the developer expects, there is no requirement that an STL implementation treat a default-initialized iterator as a synonym for for the iterator returned by end()
.
Code Block | ||||
---|---|---|---|---|
| ||||
#include <algorithm> #include <iostream> #include <vector> void f(const std::vector<int> &c) { std::vector<int>::const_iterator e; std::for_each(c.begin(), e, [](int i) { std::cout << i; }); } |
...