ElementType!string

Paolo Invernizzi paolo.invernizzi at gmail.com
Sun Aug 25 12:38:50 PDT 2013


On Sunday, 25 August 2013 at 19:25:08 UTC, qznc wrote:
> Apparently, ElementType!string evaluates to dchar. I would have 
> expected char. Why is that?

I think is because they are iterated by ranges as dchar, that's 
equivalent to iterating the unicode symbol.

If they were iterated by char, you would get during the iteration 
the singles pieces of the utf8 encoding, and usually that is not 
what an user is expecting.

Note on the other side that static assert( is(typeof(" "[0]) == 
immutable(char)) ), so you can iterate the string by chars using 
the index.

- Paolo Invernizzi


More information about the Digitalmars-d-learn mailing list