vector
,
string
, valarray
, and
array
. In the Library Fundamentals TS, there is also
string_view
. This paper introduces the term "contiguous
iterator" as a refinement of random-access iterator, without
introducing a corresponding contiguous_iterator_tag
,
which was found to break code during the Issaquah discussions of Nevin
Liber's paper N3884
"Contiguous Iterators: A Refinement of Random Access Iterators".
Iterators that further satisfy the requirements of output iterators are called mutable iterators. Nonmutable iterators are referred to as constant iterators.
Iterators that further satisfy the requirement that, for integral valuesChange in 21.4 [basic.string] paragraph 3:n
and dereferenceable iterator valuesa
and(a + n)
,*(a + n)
is equivalent to*(addressof(*a) + n)
, are called contiguous iterators. [ Note: For example, the type "pointer to int" is a contiguous iterator, butreverse_iterator<int *>
is not. For a valid iterator range [a, b) with dereferenceablea
, the corresponding range denoted by pointers is [addressof(*a)
,addressof(*a) + (b - a)
);b
might not be dereferenceable. -- end note ]
Delete in 21.4.1 [string.require] paragraph 4:The iterators supported byAbasic_string
are random access iterators (24.2.7 [random.access.iterators]).basic_string
is a contiguous container (23.2.1 [container.requirements.general]).
Add a new paragraph after 23.2.1 [container.requirements.general] paragraph 12:The char-like objects in abasic_string
object shall be stored contiguously. That is, for anybasic_string
object s, the identity&*(s.begin() + n) == &*s.begin() + n
shall hold for all values of n such that0 <= n < s.size()
.
Unless otherwise specified (either explicitly or by defining a function in terms of other functions), invoking a container member function or passing a container as an argument to a library function shall not invalidate iterators to, or change the values of, objects within that container.
A contiguous container is a container that supports random access iterators (24.2.7 [random.access.iterators]) and whose member typesChange in 23.3.2.1 [array.overview] paragraph 1:iterator
andconst_iterator
are contiguous iterators (24.2.1 [iterator.requirements.general]).
... An arrayChange in 23.3.6.1 [vector.overview] paragraphs 1 and 2:supports random access iteratorsis a contiguous container. ...The elements of an array are stored contiguously, meaning that if a is an array<T, N> then it obeys the identity&a[n] == &a[0] + n
for all0 <= n < N.
A vector is a sequence container thatChange in 26.6.10 [valarray.range] paragraph 1:supports random access iterators . In addition, itsupports (amortized) constant time insert and erase operations at the end; insert and erase in the middle take linear time. ...The elements of a vector are stored contiguously, meaning that if v is a vectorwhere T is some type otherthan bool, then it obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size()
.A vector satisfies all of the requirements of a container and of a reversible container (given in two tables in 23.2), of a sequence container, including most of the optional sequence container requirements (23.2.3 [sequence.reqmts]),
andof an allocator-aware container (Table 99), and, for an element type other thanbool
, of a contiguous container (23.2.1 [container.requirements.general]). The exceptions are ...
In the[ Drafting note: In the library fundamentals TS, section 7.4, replacebegin
andend
function templates that follow, unspecified1 is a type that meets the requirements of a mutable random access iterator (24.2.7 [random.access.iterators]) and of a contiguous iterator (24.2.1 iterator.requirements.general]) whosevalue_type
is the template parameter T and whose reference type is T&. unspecified2 is a type that meets the requirements of a constant random access iterator (24.2.7 [random.access.iterators]) and of a contiguous iterator (24.2.1 [iterator.requirements.general]) whosevalue_type
is the template parameter T and whose reference type is const T&.
]typedef implementation-defined const_iterator;A constant random-access and contiguous iterator typesuch that, for a const_iterator it, if &*(it+N) is valid, then it is equal to (&*it)+N.