Copying copy?

monarch_dodra monarchdodra at gmail.com
Fri Jul 26 08:21:39 PDT 2013


On Friday, 26 July 2013 at 14:46:23 UTC, bearophile wrote:
> monarch_dodra:
>
>> I reacted to your bug entry.
>
> Thank you very much for your comments. I am wrong all the 
> time... I have written a small answer.
>
>
>> However, copy could be improved with the knowledge that a 
>> dchar can be streamed into a series of chars (EG, the way an 
>> appender!(char[]) can handle taking a dchar), and improved to 
>> handle cases it didn't handle before.
>
> Is your improvement enough to solve this problem of mine?
>
> import std.range, std.algorithm;
> void main() {
>     char[5] arr;
>     auto r = 5.iota.map!(i => cast(char)(i + 'a'));
>     static assert(is(typeof(r.front) == char)); // OK
>     r.copy(arr[]); // error
> }
>
> Is that Issue 10718 to be closed, or do you suggest to turn it 
> into an enhancement request for your proposed improvements of 
> "copy" and "array"?
>
> Bye,
> bearophile

I suggest we change it to improvement. An different entry for 
"array" should be made though IMO.

Your example code (seems) to be failing because (apparently) 
"char[]" is not an output range for "dchar". eg: 
"char[].put(dchar)" won't compile, so that needs to be fixed 
first.

This improvement had been submitted before, and I had worked on 
it too, but it kind of fell on the side with more important fixes:
https://github.com/D-Programming-Language/phobos/pull/1000

I can put this back on my "todo" list, but to be honest, I have a 
few more important things I'd like to work on first.


More information about the Digitalmars-d-learn mailing list