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:22:36 PDT 2012
Hi,
I do not understand the following error message given the code:
string foo(string f)
{
if (f == "somestring")
{
return "got somestring";
}
return bar!(foo("somestring"));
}
template bar(string s)
{
enum bar = s;
}
I'll with dmd v2.060 get:
test.d(7): called from here: foo("somestring")
test.d(7): called from here: foo("somestring")
test.d(7): called from here: foo("somestring")
test.d(7): Error: expression foo("somestring") is not a valid template value argument
test.d(12): called from here: foo("somestring")
test.d(12): called from here: foo("somestring")
test.d(7): Error: template instance test.bar!(foo("somestring")) error instantiating
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" but instead it seems that an expression is passed. How do I
force the evaluation foo("somestring")?
I haven't found a bug on this.
Jens
More information about the Digitalmars-d
mailing list