CTFE toUpper/toLower

Philippe Sigaud philippe.sigaud at gmail.com
Wed Aug 29 22:26:41 PDT 2012


On Thu, Aug 30, 2012 at 2:13 AM, cal <callumenator at gmail.com> wrote:
> Given this code for CTFE on a string array:
>
> enum E {one, two}
> enum string[] fields = [EnumMembers!E].to!(string[]);
>
> string print(string[] fields)
> {
>     string s;
>     foreach(string field; fields)
>     {
>         s ~= field.toUpper ~ ", ";
>     }
>     return s;
> }
>
> pragma(msg, print(["one", "two"]));
> pragma(msg, print(fields));
>
> I am trying to understand why the first pragma produces correct output but
> the second one fails in std.string.toUpper (cannot interpret result ~= c at
> compile-time)?
>

And with no UFCS ? Did you try s ~= toUpper(field) ~ ", ";


More information about the Digitalmars-d-learn mailing list