DMD 1.039 and 2.023 releases

bearophile bearophileHUGS at lycos.com
Sat Jan 17 01:53:21 PST 2009


Denis Koroskin:
> void doSomething(T)(int i) {
>     if (i == 0) {
>         #if (is(T == A)) {
>             A.SomeAlias x;
>         #} else if (is(T == B)) {
>             B.SubType x;
>         #} else {
>             T x;
>         #}
>  
>         x = ... whatever
>     }
>     else
>         int y = x;
> }

A different possibility is to use {# ...  #}

        static if (is(T == A)) {#
            A.SomeAlias x;
        #} else if (is(T == B)) {#

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list