D
desktop
I have read about input, output forward etc iterators. But if I make the
following:
int myints[] = {1,2,3,4,5,1,2,3,4,5};
std::vector<int> myvector (myints,myints+10);
std::vector<int>::iterator forward_iterator = myvector.end();
I can still type "--forward_iterator" eventhough "--it" is illegal on
forward iterators.
Are there some way to specify an iterator so the compiler will give
errors if used incorrectly, like when using the keyword "const" on a
variable?
I also read that find_end uses forward_iterators, but as I understand
they provide sequential read-write access. I don't see why the write
access is needed, would an input_iterator (read-only) not be more
appropriate since find only returns unchanged info?
following:
int myints[] = {1,2,3,4,5,1,2,3,4,5};
std::vector<int> myvector (myints,myints+10);
std::vector<int>::iterator forward_iterator = myvector.end();
I can still type "--forward_iterator" eventhough "--it" is illegal on
forward iterators.
Are there some way to specify an iterator so the compiler will give
errors if used incorrectly, like when using the keyword "const" on a
variable?
I also read that find_end uses forward_iterators, but as I understand
they provide sequential read-write access. I don't see why the write
access is needed, would an input_iterator (read-only) not be more
appropriate since find only returns unchanged info?