This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RedHat 8.0 `istream_iterator' undeclared (first use this function)
- From: MR <nimrod dot bm at optusnet dot com dot au>
- To: gcc-help at gcc dot gnu dot org
- Date: 24 May 2003 21:19:38 +1000
- Subject: RedHat 8.0 `istream_iterator' undeclared (first use this function)
- References: <20030224045442.GA25932@uol.com.br>
Hello STL gurus,
I have a bit of a problem getting my iterators to work with libstdc++
3.2-7 (redhat 8.0), GCC 3.2.
with a very simple program (merges two files):
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
main(int argc, char**argv) {
if (argc < 3) {
cout << "You must supply two input files.\n";
exit(1);
}
ifstream in1(argv[1]), in2(argv[2]);
if(!in1||!in2) {
cout << "File open error\n";
exit(1);
}
merge(
istream_iterator<float>(in1),
istream_iterator<float>(),
istream_iterator<float>(in2),
istream_iterator<float>(),
ostream_iterator<float>(cout, "\n")
);
return 0;
}
I get the following complaints from the compiler:
algdemo.cpp:22: `istream_iterator' undeclared (first use this function)
algdemo.cpp:22: (Each undeclared identifier is reported only once for
each
function it appears in.)
algdemo.cpp:22: parse error before `>' token
I call the compile with g++ -g -Wall algdemo.cpp
So where am I going wrong? What do I need to do to get the
istream_iterators and ostream_iterators to work?
Thanks for your help, it is greatly appreciated.
Matt