[Issue 16075] Compiler rejects basic mixin template

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed May 25 20:52:16 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16075

--- Comment #2 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to b2.temp from comment #1)

> 
> Hi, there is an error in your code, the correct way to write your template
> is:
> 
> 
> 
> mixin template Foo(A...)
> {
>     static if (A.length)
>     {
>         void foo(A[0] a) {}
>         static if (A.length > 1) // here !!
>         {
>             mixin Foo!(A[1..$]) F;
>             alias foo = F.foo;
>         }
>     }
> }
> 
> mixin Foo!(int,string,bool);
> 
> void main() {}
> 
> 
> 
> otherwise the instanciation continues endlessly with an empty A.

No. The base case is when A.length is zero. Remove the alias, and the example
will compile.

--


More information about the Digitalmars-d-bugs mailing list