简体   繁体   English

std :: deque内存地址作为数组

[英]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: 我知道使用以下方法将向量“转换”为c样式数组是合法的:

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

Is the same also true for a std::deque? std :: deque是否也一样?

No. In general, the contents of a std::deque are not stored contiguously: 不会。通常, std::deque的内容不会连续存储:

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 与std :: vector相反,双端队列的元素不是连续存储的:典型的实现使用一系列单独分配的固定大小的数组

From here . 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM