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".
... This International Standard definesAdd a new subsection 24.2.8 [contiguous.iterators]:fivesix categories of iterators, according to the operations defined on them: input iterators, output iterators, forward iterators, bidirectional iterators,andrandom access iterators, and contiguous iterators, as shown in Table 105.
24.2.8 Contiguous iterators [contiguous.iterators]Change in 21.4 [basic.string] paragraph 3:A class or pointer type
X
satisfies the requirements of a contiguous iterator if, in addition to satisfying the requirements for random access iterators, for dereferenceablea
and(a + n)
,*(a + n)
is equivalent to*(std::addressof(*a) + n)
. [ Note: For a valid iterator range [a, b) with dereferenceablea
, the corresponding range denoted by pointers is [std::addressof(*a)
,std::addressof(*a) + (b-a)
);b
might not be dereferenceable. -- end note ]
The iterators supported byDelete in 21.4.1 [string.require] paragraph 4:basic_string
are random access iterators (24.2.7 [random.access.iterators]). In addition, the member typesiterator
andconst_iterator
are contiguous iterators (24.2.8 [contiguous.iterators]).
Change in 23.3.2.1 [array.overview] paragraph 1: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()
.
... An array supports random access iterators (24.2.7 [random.access.iterators]). In addition, the member typesChange in 23.3.6.1 [vector.overview] paragraph 1:iterator
andconst_iterator
are contiguous iterators (24.2.8 [contiguous.iterators]). ...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 that supports random access iterators (24.2.7 [random.access.iterators]). In addition, the member typesChange in 26.6.10 [valarray.range] paragraph 1:iterator
andconst_iterator
are contiguous iterators (24.2.8 [contiguous.iterators]). ...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()
.
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 mutablerandom access iterator (24.2.7 [random.access.iterators])contiguous iterator (24.2.8 [contiguous.iterators]) whosevalue_type
is the template parameter T and whose reference type is T&. unspecified2 is a type that meets the requirements of a constantrandom access iterator (24.2.7 [random.access.iterators])contiguous iterator (24.2.8 [contiguous.iterators]) whosevalue_type
is the template parameter T and whose reference type is const T&.
]typedef implementation-defined const_iterator;A constantrandom-accesscontiguous iterator typesuch that, for a const_iterator it, if &*(it+N) is valid, then it is equal to (&*it)+N.