std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]
Paul Backus
snarwin at gmail.com
Sat Jun 20 18:47:18 UTC 2020
On Saturday, 20 June 2020 at 18:34:37 UTC, Johannes Loher wrote:
> On Saturday, 20 June 2020 at 13:07:41 UTC, Paul Backus wrote:
>>
>> For non-forward ranges, there's no promise that the original
>> range (or any copies of it) will remain valid after calling
>> `rest`, so you can always implement `rest` like this:
>>
>> auto rest() {
>> this.popFront;
>> return this;
>> }
>
> Can’t make it const then... also some ranges probably cannot
> bee const by design, e.g. byLine etc.
Yes, ranges with popFront can't be const. The difference is that,
with `rest`/`tail` as the default, *some* ranges that are
currently forced to use popFront unnecessarily can be made
const-compatible.
Ranges that continue to use popFront, for whatever reason
(performance, backwards compatibility, etc.) will remain
mutable-only.
More information about the Digitalmars-d
mailing list