Share via


istream_iterator

istream_iterator

template<class U, class E = char, class T = char_traits<E> >
    class istream_iterator
        : public iterator<input_iterator_tag, U, ptrdiff_t> {
public:
    typedef E char_type;
    typedef T traits_type;
    typedef basic_istream<E, T> istream_type;
    istream_iterator();
    istream_iterator(istream_type& is);
    const U& operator*() const;
    const U *operator->() const;
    istream_iterator<U, E, T>& operator++();
    istream_iterator<U, E, T> operator++(int);
    };

The template class describes an input iterator object. It extracts objects of class U from an input stream, which it accesses via an object it stores, of type pointer to basic_istream<``E``, ``T``>. After constructing or incrementing an object of class istream_iterator with a non-null stored pointer, the object attempts to extract and store an object of type U from the associated input stream. If the extraction fails, the object effectively replaces the stored pointer with a null pointer (thus making an end-of-sequence indicator).