about std.string.representation

Ali Çehreli acehreli at yahoo.com
Thu Nov 14 04:01:04 PST 2013


On 11/13/2013 04:32 PM, bioinfornatics wrote:
> Hi,
> I try to understand which type char, dchar, wchar will give
> ubyte,ushort,uint…

And for templates, there is std.range.ElementEncodingType:

import std.stdio;
import std.range;

void foo(R)(R range)
{
     // In contrast, ElementType!R for strings is always dchar
     writeln(typeid(ElementEncodingType!R));
}

void main()
{
     string  t  = "test";
     char[]  c  = "test".dup;
     dchar[] dc = "test"d.dup;
     wchar[] wc = "test"w.dup;

     foo(t);
     foo(c);
     foo(dc);
     foo(wc);
}

Prints:

immutable(char)
char
dchar
wchar

Ali



More information about the Digitalmars-d-learn mailing list