Thread overview
mixin templates as ailas paramters
Nov 25, 2016
Nicholas Wilson
Nov 25, 2016
ketmar
Nov 25, 2016
Nicholas Wilson
November 25, 2016
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
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
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 ...