On Thursday, November 24, 2016 13:54:50 Kagamin via Digitalmars-d wrote: > On Thursday, 24 November 2016 at 13:45:40 UTC, Jonathan M Davis > > wrote: > > How so? Because someone might call range.front again without > > bothering to call popFront? > > That's what everything in std.algorithm does.
Then call popFront or drop before passing it along if you're paranoid about it. If it's a serious concern that this be fixed in general, then the obvious fix to that would be to make it so that rndGen() just called popFront before returning it. Heck, if rndGen() were guaranteed to call popFront when it was called rather than simply returning the range, then you could just do rndGen().front whenever you wanted the equivalent of rand(), making it trivial to use rndGen() both for cases where you wanted a single number and for cases where you wanted a range of them - and without worrying about front being stale. - Jonathan M Davis