Typeof woes

Artur Skawina art.08.09 at gmail.com
Thu Aug 22 01:24:10 PDT 2013


On 08/21/13 02:15, Dicebot wrote:
> typeof only accepts expressions, not types.
> 
> Workaround:
> 
> template myTypeOf(T...)
>    if (T.length == 1)
> {
>     static if (is(T))
>         alias myTypeOf = T;
>     else
>         alias myTypeOf = typeof(T);
> }

Keep in mind that 'typeof' is special - it won't evaluate the
argument. Which could be any expression (not just the subset
allowed as template parms). 

artur


More information about the Digitalmars-d-learn mailing list