at a time, I created a pointer point to a
std::vector, then I did some
resize operation to that vector, after such operations, is it safe to compare the pointer to the address of that vector to check whether the pointer point to that vector, because there might be some re-allocation of memory.
std::vector<int> vec; vector<int>* pVec = &vec; vec.reserve(10000); assert(pVec == &vec); vec = anotherVec; assert(pVec == &vec);
what is more, is it safe to compare a pointer to the first value of vector? for example:
std::vector<int> vec(1,0); int* p = &vec; // some operation here assert(p == &vec);
As I tested by myself, it seems that the first situation is safe, while the second is not, but I can't be sure.