bug with is(T == TI!TP) expression: captures templated structs but not templated functions?

Timon Gehr timon.gehr at gmx.ch
Tue Jun 25 03:41:27 PDT 2013


On 06/25/2013 12:32 PM, Timothee Cour wrote:

It is not a bug.

> template Test(alias T){
>    static if(is(T == TI!TP, alias TI, TP)){
>      enum Test=true;
>    }
>    else{
>      enum Test=false;
>    }
> }
>
> struct A(T){}
> void foo(T)(T a){}
>
> void main(){
>    static assert(Test!(A!double));
>    static assert(!Test!(foo!double)); //why is Test false?
> }
>

Because foo!double is not a type. All forms of the is-expression check 
whether the first argument is a valid type.

> This is blocking my pull request to make
> fullyQualifiedName/GetTemplateParent/GetTemplateArguments work on
> everything: right now it fails on templated functions.
>




More information about the Digitalmars-d mailing list