Search code examples
c++arraysmemory-addressdeque

std::deque memory-address as array


I know that it is legal to "convert" a vector to a c-style Array using the following method:

std:vector<char> v;
char *c = &v[0];

Is the same also true for a std::deque?


Solution

  • No. In general, the contents of a std::deque are not stored contiguously:

    As opposed to std::vector, the elements of a deque are not stored contiguously: typical implementations use a sequence of individually allocated fixed-size arrays

    From here.