Thread overview | |||||
---|---|---|---|---|---|
|
February 27, 2019 Template recursion exceeded | ||||
---|---|---|---|---|
| ||||
Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expansion |
February 27, 2019 Re: Template recursion exceeded | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michelle Long | 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. |
February 27, 2019 Re: Template recursion exceeded | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Wednesday, 27 February 2019 at 06:56:59 UTC, Nicholas Wilson wrote:
> 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.
Right, I forgot ;/ At first I wasn't using a static if then threw it in their.
|
Copyright © 1999-2021 by the D Language Foundation