MAX_CHAR

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jun 19 08:34:49 PDT 2010


On 06/19/2010 08:47 AM, Ben Hanson wrote:
> Hi there,
>
> Can anyone tell me how to get the maximum char value from a string
> type? I have a template struct which can take string or wstring and
> need to determine the character type from the string type.
>
> Thanks,
>
> Ben

Something like:

import std.stdio;

struct Widget(S) {
     enum uint MAX_CHAR = typeof(S.init[0]).max;
}

void main() {
     writeln(Widget!string.MAX_CHAR);
     writeln(Widget!wstring.MAX_CHAR);
     writeln(Widget!dstring.MAX_CHAR);
}

writes

255
65535
1114111


Andrei


More information about the Digitalmars-d mailing list