[istreambuf.iterator.general]

# 24 Iterators library [[iterators]](./#iterators)

## 24.6 Stream iterators [[stream.iterators]](stream.iterators#istreambuf.iterator.general)

### 24.6.4 Class template istreambuf_iterator [[istreambuf.iterator]](istreambuf.iterator#general)

#### 24.6.4.1 General [istreambuf.iterator.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6844)

The
class templateistreambuf_iterator defines an [input iterator](input.iterators "24.3.5.3 Input iterators [input.iterators]") that
reads successive*characters* from the streambuf for which it was constructed[.](#1.sentence-1)

operator* provides access to the current input character, if any[.](#1.sentence-2)

Each timeoperator++ is evaluated, the iterator advances to the next input character[.](#1.sentence-3)

If the end of stream is reached (streambuf_type​::​sgetc() returnstraits​::​eof()),
the iterator becomes equal to the[*end-of-stream*](#def:end-of-stream) iterator value[.](#1.sentence-4)

The default constructoristreambuf_iterator() and the constructoristreambuf_iterator(nullptr) both construct an end-of-stream iterator object suitable for use
as an end-of-range[.](#1.sentence-5)

All specializations of istreambuf_iterator shall have a trivial copy
constructor, a constexpr default constructor, and a trivial destructor[.](#1.sentence-6)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6871)

The result ofoperator*() on an end-of-stream iterator is undefined[.](#2.sentence-1)

For any other iterator value achar_type value is returned[.](#2.sentence-2)

It is impossible to assign a character via an input iterator[.](#2.sentence-3)

[ð](#lib:istreambuf_iterator)

namespace std {template<class charT, class traits = char_traits<charT>>class istreambuf_iterator {public:using iterator_category = input_iterator_tag; using value_type = charT; using difference_type = typename traits::off_type; using pointer = *unspecified*; using reference = charT; using char_type = charT; using traits_type = traits; using int_type = typename traits::int_type; using streambuf_type = basic_streambuf<charT,traits>; using istream_type = basic_istream<charT,traits>; // [[istreambuf.iterator.proxy]](istreambuf.iterator.proxy "24.6.4.2 Class istreambuf_­iterator​::​proxy"), class istreambuf_iterator​::​*proxy*class *proxy*; // *exposition only*constexpr istreambuf_iterator() noexcept; constexpr istreambuf_iterator(default_sentinel_t) noexcept;
 istreambuf_iterator(const istreambuf_iterator&) noexcept = default; ~istreambuf_iterator() = default;
 istreambuf_iterator(istream_type& s) noexcept;
 istreambuf_iterator(streambuf_type* s) noexcept;
 istreambuf_iterator(const *proxy*& p) noexcept;
 istreambuf_iterator& operator=(const istreambuf_iterator&) noexcept = default;
 charT operator*() const;
 istreambuf_iterator& operator++(); *proxy* operator++(int); bool equal(const istreambuf_iterator& b) const; friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s); private: streambuf_type* sbuf_; // *exposition only*};}
