Adam Hunyadi Adam Hunyadi - 1 year ago 69
C++ Question

Is it safe to access std::array data by address?

I would like to use bitwise data conversion on std::array objects and for this I need to know if it is safe to store the address of the array, or if there is a function that changes the data location. For example:

std::array<int, 100> array;
int* startMarker =;
(filing the array and doing operations on it)
std::cout << *startMarker << std::endl;

Thanks for the answers.

Answer Source

std::array is of static size and the addresses kept for the interned data elements are stable (unlike as with std::vector).

So yes, its safe to keep these addresses.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download