| Thread overview | |||||
|---|---|---|---|---|---|
|
November 25, 2016 mixin templates as ailas paramters | ||||
|---|---|---|---|---|
| ||||
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.
| ||||
November 25, 2016 Re: mixin templates as ailas paramters | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | 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);
}
| |||
November 25, 2016 Re: mixin templates as ailas paramters | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ketmar | 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 ...
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply