digitalmars.D.learn - mixin templates as ailas paramters
- Nicholas Wilson (16/16) Nov 24 2016 Is there any reason why
- ketmar (13/13) Nov 24 2016 On Friday, 25 November 2016 at 00:43:25 UTC, Nicholas Wilson
- Nicholas Wilson (2/15) Nov 24 2016 Hmm, maybe i was trying to do Bar!Foo!int ...
Is there any reason why
mixin template Foo(T)
{
}
Struct Bar(ailas a)
{
mixin a!int
}
doesn't work?
It gives an error saying that mixin templates are not normal
templates.
I hacked around this by making Bar take an enumeration and then
"static switch"ing on it to select the correct mixin template,
but that makes the set of mixins i can pass it closed.
It needs to be a mixin template because I need to access Bar's
this from inside Foo.
Nov 24 2016
On Friday, 25 November 2016 at 00:43:25 UTC, Nicholas Wilson
wrote:
works like a charm:
mixin template Foo(T) {
int z = 42;
}
auto Bar(alias a) () {
mixin a!int;
return z;
}
void main () {
writeln(Bar!Foo);
}
Nov 24 2016
On Friday, 25 November 2016 at 01:08:38 UTC, ketmar wrote:
On Friday, 25 November 2016 at 00:43:25 UTC, Nicholas Wilson
wrote:
works like a charm:
mixin template Foo(T) {
int z = 42;
}
auto Bar(alias a) () {
mixin a!int;
return z;
}
void main () {
writeln(Bar!Foo);
}
Hmm, maybe i was trying to do Bar!Foo!int ...
Nov 24 2016








Nicholas Wilson <iamthewilsonator hotmail.com>