#ifndef ISTREAM_ITERATORH #define ISTREAM_ITERATORH #include using namespace std; class istream_iterator { istream *p; public: istream_iterator(istream *initial_p = 0): p(initial_p) {} const int operator*() {int i; *p >> i >> ws; return i;} istream_iterator& operator++() {return *this;} friend bool operator==(const istream_iterator& it1, const istream_iterator& it2) { return (it1.p == 0 || it1.p->eof()) && (it2.p == 0 || it2.p->eof()); } }; inline bool operator!=(const istream_iterator& it1, const istream_iterator& it2) { return !(it1 == it2); } #endif