Comment #0 by erikas.aubade — 2016-05-13T20:56:31Z
DMD 2.071's new visibility rules make it so that if you're introspecting a type from inside a template, you need to locally import the module that it comes from; best practices would dictate you only import the specific symbol you're attempting to introspect. Unfortunately, none of the ways I could come up worked in every case
mixin("import " ~ moduleName!T ~": " ~ T.stringof ~ ";");
fails with templated types, as the instantiation causes the parsing to fail.
Substituting __traits(identifier, T) fails on nested types
Using a selective TemplateOf like so:
static if (__traits(compiles, TemplateOf!T)) {
private alias symb = TemplateOf!T;
} else {
private alias symb = T;
}
enum importableName = __traits(identifier, symb);
fails on non-templated classes that inherit from templated ones.
Basically, the long and short of it is that this seems like it should be a common enough use case to warrant something to help us do this without having to do a ton of CTFE string parsing and substitution.
Comment #1 by robert.schadek — 2024-12-01T16:26:48Z