The GoF book Design Patterns suggests that begin()
and end()
should be iterator methods. In C++, the iterator protocol specifies that the begin()
and end()
must be methods of the iterable object.
- why is it implemented this way? So that you can easily write something like
std::find(a.begin() +3, a.begin() + 4, 5)
? - If iterators in C++ were implemented as described in the GoF book, then these would actually be ranges?
1