Template recursion exceeded

Nicholas Wilson iamthewilsonator at hotmail.com
Wed Feb 27 06:56:59 UTC 2019


On Wednesday, 27 February 2019 at 05:45:19 UTC, Michelle Long 
wrote:
> Basically
>
> void foo(int k = 20)()
> {
>    static if (k <= 0 || k >= 100) return;
>    foo!(k-1)();
> }
>
> Error		Error: template instance `foo!-280` recursive expansion		

Yep, that return is a dynamic return, not a static one.

>    static if (k <= 0 || k >= 100) {} else:
>    foo!(k-1)();

will work.


More information about the Digitalmars-d-learn mailing list