Range functions expand char to dchar

Matt Kline via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 8 11:28:38 PDT 2015


On Tuesday, 8 September 2015 at 18:21:34 UTC, anonymous wrote:
> By design with regrets:
> http://forum.dlang.org/post/m01r3d$1frl$1@digitalmars.com
>
> On Thursday, 25 September 2014 at 19:40:29 UTC, Walter Bright 
> wrote:
>> Top of my list would be the auto-decoding behavior of 
>> std.array.front() on character arrays. Every time I'm faced 
>> with that I want to throw a chair through the window.

At least I'm not alone. :)

> You can use std.utf.byCodeUnit to get ranges of chars:

A bit verbose, but I suppose that will do.

>     /* Having char elements isn't enough. Need to turn the 
> range into an
>     array via std.array.array: */
>     auto r = regex(joined.array);
>     matchFirst("won't compile", r); /* compiles */
> }

If we have a range of char elements, won't that do? regex() uses 
the standard isSomeString!S constraint to take any range of chars.




More information about the Digitalmars-d mailing list