Partager via


istream_iterator Class

Describes an input iterator object. It extracts objects of class Type from an input stream, which it accesses through an object it stores, of type pointer to basic_istream<CharType, Traits>.

template<class Type,
    class CharType = char,
    class Traits = char_traits<CharType>,
    class Distance = ptrdiff_t,
> class istream_iterator
 : public iterator<
        input_iterator_tag,
        Type, 
        Distance, 
        const Type *,
        const Type&
    >;

Parameters

  • Type
    The type of object to be extracted from the input stream.

  • CharType
    The type that represents the character type for the istream_iterator. This argument is optional and the default value is char.

  • Traits
    The type that represents the character type for the istream_iterator. This argument is optional and the default value is char_traits<CharType>.

  • Distance
    A signed integral type that represents the difference type for the istream_iterator. This argument is optional and the default value is ptrdiff_t.

After constructing or incrementing an object of class istream_iterator with a nonnull stored pointer, the object attempts to extract and store an object of type Type 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.

Constructors

istream_iterator

Constructs either an end-of-stream iterator as the default istream_iterator or a istream_iterator initialized to the iterator's stream type from which it reads.

Typedefs

char_type

A type that provides for the character type of the istream_iterator.

istream_type

A type that provides for the stream type of the istream_iterator.

traits_type

A type that provides for the character traits type of the istream_iterator.

Operators

operator*

The dereferencing operator returns the stored object of type Type addressed by the istream_iterator.

operator->

Returns the value of a member, if any.

operator++

Either extracts an incremented object from the input stream or copies the object before incrementing it and returns the copy.

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

input_iterator_tag Struct

iterator Struct

<iterator>

Thread Safety in the C++ Standard Library

Standard Template Library