is Expression, Type Identifier : TypeSpecialization

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Jun 23 18:06:47 PDT 2010


Hi,

On the expressions page,
http://www.digitalmars.com/d/2.0/expression.html

under section 5: "is ( Type Identifier : TypeSpecialization  )" it states:

"The condition is satisfied if Type is the same as TypeSpecialization, or if Type is a class and TypeSpecialization is a base class or base interface of it. The Identifier is declared to be either an alias of the TypeSpecialization or, if TypeSpecialization is dependent on Identifier, the deduced type."

The following prints 'test':

    class one { }
    class two : one {  }
    
    alias one ONE;
    alias two TWO;
    
    static if ( is(TWO : ONE) )
        writeln("test");

But if I add an Identifier T, the 'is' expression evaluates to 0, writeln is not executed:

    class one { }
    class two : one {  }
    
    alias one ONE;
    alias two TWO;
    
    static if ( is(TWO T : ONE) )
        writeln("test");

Is this a bug, or am I doing it wrong?


More information about the Digitalmars-d mailing list