MAX_CHAR

Ben Hanson Ben.Hanson at tfbplc.co.uk
Sat Jun 19 09:15:46 PDT 2010


Hi Andrei,

== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s
article
> 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

Great, this is even easier.

Thanks,

Ben


More information about the Digitalmars-d mailing list