[littleguru]
> I wonder why the iterator is not following to the new location, when the resizing of a vector happens.
> Is that to slow or why isn't that implemented?
It would be way too expensive (both space and time). C++ is supposed to be blazingly fast, so the Standard avoids mandating anything that could be expensive. Especially when it doesn't buy anything fundamentally useful.
It would actually be more expensive than _SECURE_SCL, which is already unloved.
You can always use indices, which aren't invalidated by reallocation.
> And why is it a linked list that keeps track of the iterators and not a "vector"-like (dynamic array) construct?
_HAS_ITERATOR_DEBUGGING's singly-linked list is actually formed from the iterators themselves, which avoids performing any dynamic memory allocations. The iterators of Standard containers aren't allowed to have throwing copy ctors (23.1/10), which is exactly what dynamic memory allocations would do.
[Sven Groot]
> For one thing, the C++ standard actually specifies that a vector reallocation invalidates all iterators and pointers.
Note that the Standard's idea of invalidation is a theoretical concept. Iterators, pointers, and references can be theoretically invalidated (e.g. by vector reallocation) without being physically invalidated. For example, if we attempted and succeeded at in-place reallocation, then we wouldn't physically invalidate anything, but the Standard would still say that things have been theoretically invalidated.
> If VC would do otherwise, it would break the standard
If the Standard says that X theoretically invalidates Y, then it's conformant to make X not physically invalidate Y.
[PhrostByte]
> Raises hand as one of those C++ developers that always disables secure scl.
You have to be careful when doing this, as I mentioned in the video, if you use something like Boost.
Stephan T. Lavavej, Visual C++ Libraries Developer