Lars Gullik Bjønnes wrote: > char a[] = "Lars"; > a[-1] yields what? AFAIK the implementation is allowed to crash. >
Dead sure it can crash if you _access_ a[-1], but this doesn't takes out the fact that you can compare &a[-1] with some iterator (and it will not crash). It's the same thing as: vector<int> a(10); if(&a[11] == &*a.end()) cout << "yes" << endl; This does _not_ crash and prints yes (and in fact is perfectly valid and can even be useful). The vector::end() iterator points to an invalid position (i.e. cout << a[11] does crash) and it's not less useful for that. The same thing happends for rend() and rbegin(), they can point to invalid positions. Regards, Alfredo