Typeof woes

Dicebot public at dicebot.lv
Tue Aug 20 17:49:06 PDT 2013


On Wednesday, 21 August 2013 at 00:24:24 UTC, H. S. Teoh wrote:
> 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

It should have been T[0], not plain T, of course.


More information about the Digitalmars-d-learn mailing list