I can't convince myself that it is safe to store a pointer to a vector.end() (i.e whatever vector end() iterator returns)
Data is
std::vector<unsigned char> data;
auto end = &(*data.end());
block b(end, size);
blocks.push_back(b);
data.insert(data.end(), (unsigned char*) ptr_data, (unsigned char*) ptr_data + size);
My question is. Can this address change ( &*(data.end() ), with a condition that vector capacity pre-allocate and the client will never insert more than vector supposes to store.
So it should be a continuous region in memory, so my assumption that vector will not do any memove operation and therefore I can store pointers that will point to different elements. (so here block store a pointer to whatever data.end() point to (before insertion to data vector) and metadata about variable size data inside that data vector.
Thank you.