digitalmars.D.bugs - [Issue 14848] New: template alias on struct field without instance
- via Digitalmars-d-bugs (29/29) Jul 29 2015 https://issues.dlang.org/show_bug.cgi?id=14848
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: nobody puremagic.com Reporter: remi.thebault outlook.com 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 --
Jul 29 2015