struct S {
static if(hasIndirections!(typeof(this))) {}
}
template hasIndirections(T)
{
enum hasIndirections = hasIndirectionsImpl!(typeof(T.init.tupleof));
}
template hasIndirectionsImpl(T...)
{
static if (!T.length)
{
enum hasIndirectionsImpl = false;
}
else
{
enum hasIndirectionsImpl = true;
}
}
This is wrong because S isn't fully defined yet, so S.init.tupleof makes no sense. However, the error message is extremely obtuse:
Error: struct S no size yet for forward reference
Comment #1 by andrej.mitrovich — 2014-04-28T12:14:51Z
The new diagnostic is:
-----
test.d(2): Error: forward reference of variable hasIndirections
test.d(2): Error: template instance test.hasIndirections!(S) error instantiating
-----
But I'm not sure this is better.
Comment #2 by dlang-bugzilla — 2017-07-19T04:54:30Z