The following code doesn't compile because the generated type name needs to be available inside the mixin's scope, whereas it's actually in another module.

auto makeWith(string className, Args…)(auto ref Args args) {
mixin("return makeWith!(I", className, "Factory)(args);"); // Fowarded to implementation of makeWith below
}

auto makeWith(T, Args…)(auto ref Args args) … // This is the implementation

The idea is that users could type (for example) makeWith!`Calendar`(…) instead of the longer makeWith!ICalendarFactory(…).

I tried mixing in an import statement with the help of std.traits.moduleName so that the I...Factory type would be available but again the compiler complains that it's undefined.

Has anyone had a similar need and come up with a solution?

Reply via email to