This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TC1 status.

69. Must elements of a vector be contiguous?

Section: 21.3.11 [vector] Status: TC1 Submitter: Andrew Koenig Opened: 1998-07-29 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [vector].

View all issues with TC1 status.


The issue is this: Must the elements of a vector be in contiguous memory?

(Please note that this is entirely separate from the question of whether a vector iterator is required to be a pointer; the answer to that question is clearly "no," as it would rule out debugging implementations)

Proposed resolution:

Add the following text to the end of 21.3.11 [vector], paragraph 1.

The elements of a vector are stored contiguously, meaning that if v is a vector<T, Allocator> where T is some type other than bool, then it obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size().


The LWG feels that as a practical matter the answer is clearly "yes". There was considerable discussion as to the best way to express the concept of "contiguous", which is not directly defined in the standard. Discussion included: