second parameter to istream_iterator class template

S

subramanian100in

Consider:

template <typename T,
typename charT = char,
typename traits = char_traits<charT>,
typename Difference = ptrdiff_t>
class istream_iterator;

I pass only the element type like 'int' as in
istream_iterator<int> isi(cin);

In the above construction, the second parameter to the class template
istream_iterator is the default argument 'char' which is taken by
default because I did not supply the second argument.

What other types can we specify as the second argument to the second
parameter ? What is the significance of this second parameter and
where is it useful to provide a programmer-supplied second
argument(kindly provide a code sample for this) ?

Suppose 'Test' is a user-defined class type. Can we write like:
istream_iterator<int, Test> isi(cin);
What is its meaning of passing the second argument which is different
from the default 'char' ?

Kindly explain.

Thanks
V.Subramanian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top