https://issues.dlang.org/show_bug.cgi?id=14848
Issue ID: 14848
Summary: template alias on struct field without instance
requires 'this'
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
template offsetof_member(alias member)
{
size_t get() { return member.offsetof; }
}
struct S { int f }
int main (string[] args)
{
auto i = offsetof_member!(S.f).get();
return 0;
}
this code triggers:
Error: 'this' is only defined in non-static member functions, not main
despite no instance is involved.
Marking get with 'static' removes the compiler error
--