Stream iterators and buffers?

Do stream iterators, such as std::istreambuf_iterator<char>, read a chunk of bytes internally, or do they read the stream one byte at a time?

Because I am thinking to write a BufferedFile class which uses an std::vector<char>.
(If you have a better idea, go ahead.)
Last edited on
The iterators read from the stream's in-memory buffer one byte at a time.
Just to be clear: at the moment when the iterator reads a byte, it reads it from a chunk of the file, which is in memory acting as a buffer?
The moment the iterator reads a byte, it advances a pointer in the associated streambuf object to point to the next byte in the buffer. If the pointer reaches the end of the buffer, streambuf::underflow() reads up another chunk from the file.
Topic archived. No new replies allowed.