Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 804
Thomas Sparber Avatar asked Jul 05 '26 18:07

Thomas Sparber


1 Answers

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.

like image 103
Baum mit Augen Avatar answered Jul 07 '26 07:07

Baum mit Augen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!