A vector will check for border checks if you use the at() function, for example:
std::vector<int> v(5); v.at(3) = 10; v.at(5) = 20;
However, if you use operator[] , border checking is not performed. (And access to non-existent elements leads to undefined behavior.)
It should be noted, however, that most implementations will be able to include border checking on all iterators, which is discussed in the answers here . By default, VS2008 and below are included in Debug and Release, VS2010 only works in Debug. gcc requires that you define _GLIBCXX_DEBUG to get validated iterators.
GManNickG
source share