digitalmars.D.learn - Template recursion exceeded
- Michelle Long (7/7) Feb 26 2019 Basically
- Nicholas Wilson (4/13) Feb 26 2019 Yep, that return is a dynamic return, not a static one.
- Michelle Long (4/20) Feb 26 2019 Right, I forgot ;/ At first I wasn't using a static if then threw
Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expansion
Feb 26 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 expansionYep, that return is a dynamic return, not a static one.static if (k <= 0 || k >= 100) {} else: foo!(k-1)();will work.
Feb 26 2019
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:Right, I forgot ;/ At first I wasn't using a static if then threw it in their.Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expansionYep, that return is a dynamic return, not a static one.static if (k <= 0 || k >= 100) {} else: foo!(k-1)();will work.
Feb 26 2019