No. That's not what it means. First, you cannot cast a deque
into void*
. The two will have different sizes, and this will break the object.
What it actually means is that you can do:
vector<int> myVec = ...;
int* theBuffer = &myVec[0]; // In C++ 11, you can also do myVec.data() instead
And theBuffer
will be a contiguous segment of memory, so you can pass it to a C function expecting a pointer for example (see below), access it using pointer arithmetic, etc.
You cannot do this with a deque
, as it's internal representation doesn't provide such guarantees. Note that this concerns itself with the data stored inside a vector
or deque
, not with the object itself. In case you'd like to store a pointer to a deque
in a void*
, you're free to do so.
// Example: A C function
extern "C" void a_c_function(int* data, const size_t num_elements);
// Invoking it on a vector's elements
a_c_function(&myVec[0], myVec.size());