Reputation: 42235
According to the cppref page of std::vector
:
iterator
LegacyRandomAccessIterator
Also from another cppref page:
The following standard library types are LegacyContiguousIterators:
vector::iterator
for value_type other than bool.
Which is correct?
Upvotes: 1
Views: 668
Reputation: 238311
Both are correct. All vector iterators are random access iterators. All vector iterators except those of vector of bool are contiguous iterators. Note that all contiguous iterators are also random access iterators.
The former claim does simply not provide as much information, and may have not been updated since changes from c++17 which introduced the name for for the requirements of contiguous iterator.
Upvotes: 6
Reputation: 15813
std::vector<T>::iterator
(for T
other than bool
) is a contiguous iterator.
A
vector
meets all of the requirements of a container and [...] for an element type other thanbool
, of a contiguous container.
[container.requirements.general]/13 (emphasis mine):
A contiguous container is a container whose member types iterator and const_iterator meet the Cpp17RandomAccessIterator requirements ([random.access.iterators]) and model contiguous_iterator ([iterator.concept.contiguous]).
According to the cppref page of
std::vector
:
iterator
LegacyRandomAccessIterator
It doesn't mean that the iterator is not a contiguous iterator. It's not even talking about contiguous iterator.
The same page also mentions:
std::vector
(forT
other thanbool
) meets the requirements of [...] ContiguousContainer [...].
And the page of ContiguousContainer says:
The type
X
satisfies ContiguousContainer if
- [...]
- The member types
X::iterator
andX::const_iterator
are LegacyContiguousIterators
Upvotes: 4