typeof(typename) fails silently

Jarrett Billingsley jarrett.billingsley at gmail.com
Tue Sep 16 15:44:49 PDT 2008


On Tue, Sep 16, 2008 at 6:17 PM, Denis Koroskin <2korden at gmail.com> wrote:
> On Tue, 16 Sep 2008 22:43:08 +0400, BCS <ao at pathlink.com> wrote:
>
>> Reply to Sean,
>>
>>
>>> I'm of two minds on this.  The is expression already requires whatever
>>> it contains to be a type or there will be a compile-time error, but
>>> with the change to typeof we no longer have a bullet-proof way of
>>> ensuring that something is a type.  So either we use is(T) and hope T
>>> is a type or use is(typeof(T)) and hope T is not a type (because if T
>>> is a type then the condition will silently fail).  Neither is ideal,
>>> for obvious reasons.
>>>
>>
>> is(T) || is(typeof(T))
>>
>> ??
>>
>>
>
> template isType(T)
> {
>        const bool isType = true;
> }
>
> template isType(alias T)
> {
>        const bool isType = false;
> }
>
> Stdout(isType!(int));
> Stdout(isType!(5));
>
> ??


D2 only.


More information about the Digitalmars-d-bugs mailing list