join of range of ranges?

bearophile bearophileHUGS at lycos.com
Sun Sep 22 13:26:59 PDT 2013


Peter Alexander:

> The problem is that you are trying to map a range of range of 
> chars with a range of dchars.
>
> auto r2 = [1, 2]
>               .map!(x => [1, 2].map!(y => cast(dchar)'*'))
>               .join("_");
>
> This works.

I see, thank you. When I ask a question it seems my brain 
switches off a bit :-)


> I really wish character literals in D where always dchar.

This is supported:

void main() {
     auto s1 = "hello"w;
     auto s2 = "hello"d;
}


So, what about adding support for this?

void main() {
     auto c1 = 'X'w;
     auto c2 = 'X'd;
     static assert(is(typeof(c1) == wchar));
     static assert(is(typeof(c2) == dchar));
}


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list