Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is string::iterator necessarily a random_access_iterator?

Tags:

c++

iterator

stl

This page states that string::iterator and string::const_iterator are "compiler specific iterator types." Does this mean that that string::iterator made be in a category other than random_access_iterator?

like image 976
ThomasMcLeod Avatar asked Jul 10 '12 21:07

ThomasMcLeod


2 Answers

ISO C++03, 21.3-2 states:

(...)Additionally, because the iterators supported by basic_string are random access iterators(...)

So yes, those are necessarily random access iterators.

like image 112
mfontanini Avatar answered Nov 15 '22 06:11

mfontanini


Looking at N3376 21.4/3

The iterators supported by basic_string are random-access iterators.

For such tasks its always a good idea to have a standard (or draft) at hand. It takes a while to get used to looking up things there, but it is the first hand resource.

like image 44
pmr Avatar answered Nov 15 '22 08:11

pmr