Template constraints error messages using cputs()
bearophile
bearophileHUGS at lycos.com
Fri Aug 6 09:49:48 PDT 2010
Andrei Alexandrescu:
> pragma(msg, "Is this what you need?");
You are right, in some situations it works :-)
But you have to guard the pragma(msg) with a static if, so if your template constraint is a CTFE (that uses a normal 'if' instead of a 'static if') you can't use it, while ctputs() is OK, this shows the error message:
bool isGoodFoo(int x) {
if (x > 10) {
return true;
} else {
pragma(msg, "no good");
// ctputs("no good");
return false;
}
}
void foo(int N)() if (isGoodFoo(N)) {}
void main() {
foo!(20)();
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list