[Issue 14848] New: template alias on struct field without instance requires 'this'
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 29 15:59:10 PDT 2015
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 at puremagic.com
Reporter: remi.thebault at 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
--
More information about the Digitalmars-d-bugs
mailing list