I have this simple code:
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?