Schroedinger's Ranges
Steven Schveighoffer
schveiguy at gmail.com
Thu Jun 3 13:44:55 UTC 2021
On 6/3/21 9:00 AM, kdevel wrote:
>>>> a) What is the rationale behind not making byLineCopy the default?
>>>
>>> byLine was the original implementation. byLineCopy was added later
>>> after the need for it became apparent.
>>
>> See:
>>
>> https://forum.dlang.org/post/lg4l7s$11rl$1@digitalmars.com
>
> THX. BTW byLineCopy defaults to immutable char. That's why one has to use
>
> auto tmp = File(filename).byLineCopy!(char, char);
>
> or
>
> auto tmp = File(filename).byLine.map!dup;
>
>
I was going to suggest use byLineCopy!(char, char), because the second
option with map makes a copy every time you call front.
And, my goodness, that is backwards for the template parameters. The
terminator type should be determined by IFTI, it should never have been
the first template parameter!
-Steve
More information about the Digitalmars-d-learn
mailing list