[Issue 12729] New: mixins don't work in traits
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat May 10 09:17:01 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12729
Issue ID: 12729
Summary: mixins don't work in traits
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: vlevenfeld at gmail.com
const bool has_attribute (T, string member, alias attribute) ()
{
// ok
mixin(
`foreach (type; __traits (getAttributes, T.`~member~`))`
`static if (is (type == attribute))`
`return true;`
);
// ok
foreach (type; mixin(`__traits (getAttributes, T.`~member~`)`))
static if (is (type == attribute))
return true;
// doesn't compile, member is not accessible error
foreach (type; __traits (getAttributes, mixin(`T.`~member)))
static if (is (type == attribute))
return true;
return false;
}
--
More information about the Digitalmars-d-bugs
mailing list