Slides from my ACCU Silicon Valley talk
bearophile
bearophileHUGS at lycos.com
Tue Dec 14 00:42:40 PST 2010
Walter:
> Adding such error messages misses the point of constraints. The idea is that
> template overloading is based on constraints. Given 3 templates with 3
> constraints, overload resolution picks the one with constraints that pass.
> Giving error messages for the others is wrong.
You are right, I miss things all the time :-) Thank you for your patience.
> If you want it to produce error messages if the instantiation is wrong, the
> correct way is to use static asserts within the template body. No additional
> features serve any purpose.
If the purpose is to produce error messages if the instantiation is wrong, then using a "static precondition" instead of normal free static asserts may give a bit better error messages (errors at the instantiation point instead of inside the template). But I guess this is just a limit of the compiler, not a problem of the language...
Bye,
bearophile
More information about the Digitalmars-d
mailing list