CTFE calling a template: Error: expression ... is not a valid template value argument

Jens Mueller jens.k.mueller at gmx.de
Thu Sep 20 14:56:07 PDT 2012


Simen Kjaeraas wrote:
> On Thu, 20 Sep 2012 23:22:36 +0200, Jens Mueller
> <jens.k.mueller at gmx.de> wrote:
> 
> >string foo(string f)
> >{
> >    if (f == "somestring")
> >    {
> >        return "got somestring";
> >    }
> >    return bar!(foo("somestring"));
> >}
> >
> >template bar(string s)
> >{
> >    enum bar = s;
> >}
> 
> >In line 7 I call the template bar. But I call with the string that is
> >returned by the CTFE of foo("somestring") which should return "got
> >somestring"
> 
> When's it gonna get around to doing that? In order to figure out the
> return value of foo("somestring"), it will have to figure out the
> return value of foo("somestring"), and to do that...

There is no endless recursion. Note that foo("somestring") returns "got
somestring".
Am I wrong?

Jens


More information about the Digitalmars-d mailing list