about istream_iterator

B

ben

Is istream_iterator<> and ostream_iterator<> supposed NOT to be included in
<iostream>? The following example compiles in VC 7.1 but not with gcc 3.4.3

#include <iostream>
#include <deque>
#include <algorithm>

int main()
{
using namespace std;

deque<int> ls;
copy(istream_iterator<int>(cin), istream_iterator<int>(),
back_inserter(ls));
sort(ls.begin(), ls.end());
copy(ls.begin(), ls.end(), ostream_iterator<int>(cout));
return 0;
}

ben
 
M

Mike Wahler

ben said:
Is istream_iterator<> and ostream_iterator<> supposed NOT to be included
in
<iostream>?

<iostream> is not prohibited from declaring those
types, but neither is it required to do so.

The header which will guarantee the declarations
of 'istream_iterator' and 'ostream_iterator
is said:
The following example compiles in VC 7.1 but not with gcc 3.4.3

#include <iostream>
#include <deque>
#include <algorithm>

int main()
{
using namespace std;

deque<int> ls;
copy(istream_iterator<int>(cin), istream_iterator<int>(),
back_inserter(ls));

sort(ls.begin(), ls.end());
copy(ls.begin(), ls.end(), ostream_iterator<int>(cout));
return 0;
}

-Mike
 
B

ben

Thanks!

ben


Mike Wahler said:
<iostream> is not prohibited from declaring those
types, but neither is it required to do so.

The header which will guarantee the declarations
of 'istream_iterator' and 'ostream_iterator


-Mike
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top