September 27th, 2010, 12:52 AM
Use of input iterators
I recently came across input iterators in STL, but couldn't find out any scenario in which they might be used? (E.g. output iterators can be used along with copy() function to print the container items to console or a file).
Can anyone help me with this one?
September 27th, 2010, 02:30 AM
Re: Use of input iterators
Since forward iterators are input iterators, if you have an algorithm that works as efficiently with input iterators as with forward iterators, then you might as well write it with input iterators in mind so that it would work with forward iterators too, even if it never actually gets used with input iterators that are not forward iterators.
For example, you could use input iterators to initialise a container, just as you could use the iterators from another container to initialise that container.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.