-
September 26th, 2010, 11:52 PM
#1
Use of input iterators
Hi all,
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, 01:30 AM
#2
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|