Shouldn't hasSwappableElements work on char arrays?

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Feb 24 11:42:38 PST 2011


On 2/24/11, Jesse Phillips <jessekphillips+D at gmail.com> wrote:
> Andrej Mitrovic Wrote:
>
>> Now I see why using char[] fails. It's because [ElementType!(R).init];
>> returns a dchar[].
>
> Yep, Unicode for the win. dchar[] is swappable.
>

Oh looks like you're right. I can use reverse on dchar[]. Weird, I
thought I've already tried that.

P.S. Why do I have to use this gibberish syntax?:

dchar[] test = to!(dchar[])("test");

Isn't the compiler smart enough to do this for me automatically? It's
a string literal..

Still, I don't see why char arrays should fail on hasSwappableElements
when swap can be used on char arrays?


More information about the Digitalmars-d mailing list