Check the next approach too:
class MyIterator : istream_iterator<char>
{
public:
MyIterator( istream& stream )
: MyIterator( stream, stream.tellg() )
{
}
private:
MyIterator( istream& stream, istream::pos_type pos )
: istream_iterator( stream ), startPos( pos )
{
}
istream::pos_type const startPos;
};