opIndex, opSlice, length for joiner?
Maverick Chardet via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jan 22 04:00:02 PST 2016
On Friday, 22 January 2016 at 11:23:05 UTC, Jonathan M Davis
wrote:
> Arguably, walkLength shouldn't even accept a range that isn't a
> forward range, since if it's not, then walkLength is just going
> to eat the range. As for calling save, there's no point. It's
> too late as soon as you've passed the range into the function,
> since that copied the range, which is undefined behavior due to
> the fact that the exact semantics of copying a range vary
> wildly depending on how a range is implemented. In generic
> code, if you want to use a range after passing it to a
> function, you have to call save and pass that to the function;
> otherwise, you get undefined behavior when you do anything with
> the range after passing it to the function.
Yes actually this was my point, why not forcing the range to be a
forward range? The only advantage I see is that it allows to
count the number of elements of an input range, but then I guess
it would need to be mentioned in the documentation somewhere,
what do you think?
Yes my code is wrong sorry about that, I was just trying to
figure out how to force the saving in some way...
More information about the Digitalmars-d
mailing list