CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 29 Jul 2025 02:25:32 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/iterator/istreambuf_iterator/
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 29 Jul 2025 02:25:33 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"8fcc-QV/GUzPj+Dsk5CdM8uhx6QIGLqA"
Content-Encoding: gzip
Istreambuf iterators are input iterators that read successive elements from a stream buffer.
They are constructed from a basic_streambuf object open for reading, to which they become associated.
This kind of iterator has a special state as an end-of-stream iterator, which is acquired when the end of the stream is reached, and is also the resulting value of a default-constructed object: This value can be used as the end of a range in any function accepting iterator ranges to indicate that the range includes all the elements up to the end of the input buffer.
It is defined with a behavior similar to:
Header
Possible output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<iterator>
- iterator
- iterator_traits
functions
- advance
- back_inserter
-
beginC++11
- distance
-
endC++11
- front_inserter
- inserter
-
make_move_iteratorC++11
-
nextC++11
-
prevC++11
iterator categories
predefined iterators
- Reference
- <iterator>
- istreambuf_iterator
class template
<iterator>
std::istreambuf_iterator
template <class charT, class traits=char_traits<charT> > class istreambuf_iterator;
Input stream buffer iterator
- iterator
- istreambuf_iterator
Istreambuf iterators are input iterators that read successive elements from a stream buffer.
They are constructed from a basic_streambuf object open for reading, to which they become associated.
This kind of iterator has a special state as an end-of-stream iterator, which is acquired when the end of the stream is reached, and is also the resulting value of a default-constructed object: This value can be used as the end of a range in any function accepting iterator ranges to indicate that the range includes all the elements up to the end of the input buffer.
It is defined with a behavior similar to:
|
|
Header
<iterator>
defines the comparison with operator==
and operator!=
: Two istreambuf_iterators compare equal if both are end-of-stream iterators or neither is, regardless of the streambuf object they use.Template parameters
- charT
- Character type. This is the first template parameter in the basic_streambuf object.
- traits
- Character traits. This is the second template parameter in basic_streambuf object.
Member types
member | definition in istreambuf_iterator | description |
---|---|---|
streambuf_type | basic_streambuf<charT,traits> | Type of the associated basic_streambuf object |
istream_type | basic_istream<charT,traits> | |
iterator_category | input_iterator_tag | Input iterator |
value_type | T | Type of the elements pointed by the iterator |
char_type | charT | Type of the characters handled by the associated stream buffer |
traits_type | traits | Character traits for associated stream buffer |
int_type | traits::int_type | Int type to represent character values or end-of-file |
difference_type | traits::off_type | |
pointer | charT* | |
reference | charT& |
member | definition in istreambuf_iterator | description |
---|---|---|
streambuf_type | basic_streambuf<charT,traits> | Type of the associated basic_streambuf object |
istream_type | basic_istream<charT,traits> | |
iterator_category | input_iterator_tag | Input iterator |
value_type | T | Type of the elements pointed by the iterator |
char_type | charT | Type of the characters handled by the associated stream buffer |
traits_type | traits | Character traits for associated stream buffer |
int_type | traits::int_type | Int type to represent character values or end-of-file |
difference_type | traits::off_type | |
pointer | unspecified | |
reference | charT |
Member functions
- constructor
- istreambuf_iterator objects are constructed from either a basic_streambuf object or a basic_istream object.
The default constructor constructs an end-of-stream iterator and the copy constructor constructs a copy of the iterator passed as argument. operator*
- Returns the current value in the stream buffer.
operator++
- Advances the position of the basic_streambuf object by one element.
proxy
- Temporary type returned by the post-increment operator (which can be implicitly converted to the class type). A member class is just one of the possible ways to preserve a streambuf_iterator value. Some implementations of istreambuf_iterator may not have this member class if they use an alternate method.
Example
|
|
Possible output:
Please, enter your name: HAL 9000 Your name is HAL 9000. |
See also
- ostreambuf_iterator
- Output stream buffer iterator (class template)
- input_iterator_tag
- Input iterator category (class)
- istream
- Input stream (class)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us