Constraints error messages [Was: Re: Constrained Templates]

bearophile bearophileHUGS at lycos.com
Tue Jun 15 02:06:00 PDT 2010


BCS:

>I like the idea, but how should it interact with overloaded templates?<

The syntax/semantics I have shown is just a starting point, there are probably way better ways to reach the same goal. For example a kind of run-time error/exception for templates that shows an error message and removes the template from the list of possible templates.

Regarding overloaded templates, those else clauses are meant to be useful mostly when there is no template overloading, they are designed to be useful not for the usual purpose of constrains, that is to remove templates from the pool of overloads, but mostly when you have a single template that has input types and values that must satisfy some requirements. So it's a grubby idea that needs more thinking :-)

Bye,
bearophile


More information about the Digitalmars-d mailing list