How about "auto" parameters?

bearophile bearophileHUGS at lycos.com
Fri Jun 3 10:02:05 PDT 2011


Andrej Mitrovic:

> as a templated function gets several
> constraints it's impossible to figure out which constraint failed just
> by looking at the error message. The only thing you ever get back is:
> "<complex template declaration> does not match any function template
> declaration"
> "<complex template declaration> cannot deduce template function from
> argument types <your arguments here>"
> 
> You get to see which arguments you've passed, but not which of the
> constraints failed. If you wrote the template it might be easy to
> figure out that you can't pass a certain type of argument, but if you
> didn't write it it's hard to figure out what went wrong.

This is a problem that I've discussed some in past. I think it's worth discussing some more about a possible way to add user defined error messages (like the second argument of a static assert) to template constraints. To do this it's good to have first of all a short list of typical use cases where we'd like to add some messages.

Bye,
bearophile


More information about the Digitalmars-d mailing list