Can't put a const(char)[] into a char[]

Steven Schveighoffer schveiguy at yahoo.com
Sat Apr 21 23:56:31 UTC 2018


On 4/21/18 7:30 PM, Nicholas Wilson wrote:

> "Use .representation" would be the official answer for the second hack.

I have since discovered that I can use byCodeUnit, but I'm still annoyed 
that this is required.

I *think* that this is the only problem:

https://github.com/dlang/phobos/blob/master/std/range/primitives.d#L365

Essentially, here is the block:

     //Optional optimization block for straight up array to array copy.
     else static if (isDynamicArray!R && !isNarrowString!R && 
isDynamicArray!E && is(typeof(r[] = e[])))
     {
         immutable len = e.length;
         r[0 .. len] = e[];
         r = r[len .. $];
     }

If we just take out the !isNarrowString!R, I think it will just work, 
and probably cause no problems. I have NO IDEA why we are purposely 
shooting ourselves in the foot here.

I'm going to at least try it (PR forthcoming).

There are a few bits inside put that are supposed to cater to narrow 
strings, I'm not sure why it's not working.

-Steve


More information about the Digitalmars-d mailing list