Error: Declaration is not yet implemented in CTFE
Daniel Murphy via Digitalmars-d
digitalmars-d at puremagic.com
Fri Nov 28 14:41:32 PST 2014
"bitwise" wrote in message news:bzzwikiplqydlzmphllp at forum.dlang.org...
> The docs for template mixins do show mixins inside functions, so is this a
> bug, or is there something else I'm doing wrong?
Both a bug, and you're doing something wrong. CTFE should be giving you a
'cannot read static variable at compile time' error.
Try this:
import std.traits;
class ModInfo {
}
const(ModInfo) moduleInfo(alias MODULE) = new ModInfo(); // 1
const(ModInfo) getModuleInfo(alias mod)() {
static if(__traits(hasMember, mod, "__module_info")) {
return __traits(getMember, mod, "__module_info");
} else {
return moduleInfo!mod;
}
}
void main() {
static const(ModInfo) info = getModuleInfo!(main);
}
The 'unique ModInfo per module' is done by the templated variable 1.
More information about the Digitalmars-d
mailing list