Typeof woes

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Aug 20 17:22:51 PDT 2013


On Wed, Aug 21, 2013 at 02:15:06AM +0200, 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);
> }

Clever. I may have to add this to my personal code library. :)


T

-- 
Everybody talks about it, but nobody does anything about it!  -- Mark Twain


More information about the Digitalmars-d-learn mailing list