On 3/27/2014 2:13 PM, Steven Schveighoffer wrote:
Note that a stream makes a terrible range, simply because of what you say -- reading is destructive, and determining emptiness is dependent on reading. You need a buffered stream to make a good range, and then the logic becomes much more straightforward.
The range becomes the one element buffer in this case. It is completely workable.
The awkwardness for shoehorning streams into ranges I see is that the advancement (popFront) and the check for termination (empty) are decoupled, when in reality they are synced for a stream. This REQUIRES a sticky bit for popFront to communicate with empty on whether it is EOF or not.
The range protocol is designed to work with streams. It's a giant fail if they do not, or if you want to create a separate, non-range universe to deal with streams.
Even a single byte buffer is not enough, you need a bool to indicate the stream is done.
Right. But empty for a stream still has to read. Just follow the protocol, and the range will work, even with streams.
