If you have an STL vector which has been resized, is it safe to take the address of element 0 and assume the rest of the vector will follow in memory?
e.g.
vector<char> vc(100); // do some stuff with vc vc.resize(200); char* p = &vc[0]; // do stuff with *p
Yes, that is a valid assumption (*).
From the C++03 standard (23.2.4.1):
(*) … but watch out for the array being reallocated (invalidating any pointers and iterators) after adding elements to it.