subramanian100in@yahoo.com, India wrote:
> vector and deque provide similar operations like operator[]. vector
> stores the elements contiguously. Does the deque also store the
> elements contiguously in order to provide operations similar to the
> vector ?. Does the standard say anything regarding how the elements
> should be stored in vector and deque ?
The standard specifies that elements in a vector are stored contiguously in
memory. It does not specify any storage layout for deque. However, the
complexity specifications for deque make are somewhat incompatible with
contiguous storage layout and, to my knowledge, std::deque is usually
implemented as a collection of contiguous pages using one more level of
indirection to provide operator[].
Best
Kai-Uwe Bux