Partial Specialization using Static If

Xinok xnknet at gmail.com
Sun Dec 24 22:07:36 PST 2006


> But you can say this:
>
> static if (is(T U == U*))
>
> U is then declared to be an alias of the type T is a pointer to (and it
> only exists within the static if's scope).
>
> Assuming T is int*, you get
>
> static if (is(int* U == int*))
>      static assert(is(U == int));
>
> This works more generally, too:
>
> static if (is(T U == U[]))
>
> That determines if T is a dynamic array, and U becomes an alias for the
> type of an element of the array.

Thanks, I didn't know you can do that.



More information about the Digitalmars-d mailing list