On Sunday, 9 December 2012 at 19:24:24 UTC, js.mdnq wrote:
In this particular case you can do this:
mixin template GenStruct(string stringname)
{
struct S
{
....
}
mixin("alias S " ~ stringname ~ "alpha;");
}
But what if I use more than one mixin? I'll have multiple
structs
with the same name.
That's not an issue.
"If two different mixins are put in the same scope, and each
define a declaration with the same name, there is an ambiguity
error when the declaration is referenced" (note: when it's
referenced, not when it's declared)
and
"If the name of a declaration in a mixin is the same as a
declaration in the surrounding scope, the surrounding declaration
overrides the mixin one"
- http://dlang.org/template-mixin.html