Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-09-06 01:00:21


> Assuming you're right on upcoming specs ...

Here is the entry from the committee issues list:

69. Must elements of a vector be contiguous?

Section: 23.2.4 lib.vector Status: Ready Submitter: Andrew Koenig
Date: 29 Jul 1998

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 23.2.4 [lib.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().

Rationale:

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:

  An operational definition similar to the above proposed resolution is
  already used for valarray (26.3.2.3).

  There is no need to explicitly consider a user-defined operator& because
  elements must be copyconstructible (23.1 para 3) and copyconstructible
  (20.1.3) specifies requirements for operator&.

There is no issue of one-past-the-end because of language rules.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk