On Monday, 24 March 2014 at 22:26:10 UTC, Joseph Rushton Wakeling
wrote:
On 24/03/14 14:20, Dicebot wrote:
I think there is one design mistake with current InputRange
rules that makes
usage so inconsistent. We have `empty` but don't have any
distinct `not yet
started` state. If calling `popFront` at least once was
required before
accessing `front`, I can't imagine the case where having any
non-trivial code in
`front` would have been necessary.
I floated some ideas along those lines, for a "first" method
that would be automatically called immediately before the first
call to front, popFront, etc., whatever came first.
I was thinking about something more simple. Current pattern is:
while (!r.empty)
{
auto useme = r.front;
r.popFront;
}
And I think this would have been more practical:
r.popFront;
while (!r.empty)
{
// same
}
So every range is supposed to start in "init" state and provide
data only after first popFront. No other changes. It is not a
silver bullet but looks like an improvement over current design
to me.