typeof(func!0) != typeof(func!0())
    Andrey Zherikov 
    andrey.zherikov at gmail.com
       
    Mon Aug 22 04:39:18 UTC 2022
    
    
  
I have this simple code:
```d
struct U
{
     auto ref func(int i)() { return this; }
}
void main()
{
     {
         alias type = typeof(U().func!0);
         pragma(msg, type);  		// pure nothrow @nogc ref @safe U() 
return
         pragma(msg, is(type : U));  // false
         auto u = U().func!0;
         pragma(msg, typeof(u));		// U
     }
     {
         alias type = typeof(U().func!0());
         pragma(msg, type);  		// U
         pragma(msg, is(type : U));  // true
         auto u = U().func!0();
         pragma(msg, typeof(u));		// U
     }
}
```
Why does `typeof(U().func!0)` != `U`? How can I check that the 
returned value has type `U` in this case?
    
    
More information about the Digitalmars-d-learn
mailing list