typeof(func!0) != typeof(func!0())

Ali Çehreli acehreli at yahoo.com
Mon Aug 22 05:25:50 UTC 2022


On 8/21/22 21:39, Andrey Zherikov wrote:

 >          alias type = typeof(U().func!0);
 >          pragma(msg, type);          // pure nothrow @nogc ref @safe U()
 > return

This is where the @property keyword makes a difference:

     @property auto ref func(int i)() { return this; }

Now U().func!0 will be a call in your expression. But @property is not 
recommended (deprecated?).

But I think std.traits.ReturnType is more explicit and does work in this 
case:

         import std.traits;
         alias type = ReturnType!(U().func!0);

Ali



More information about the Digitalmars-d-learn mailing list