On 02/10/12 14:04, Timon Gehr wrote:
> On 02/10/2012 02:47 AM, bearophile wrote:
>> An alternative is to give an else to the template constraints, but the error
>> message is at the bottom of the function, making it not easy to find, so I
>> don't like this syntax:
>>
>>
>> int spam(T)(T x) if (IsFoo!T || IsBar!T) {
>> // ...
>> } else {
>> __ctfeWriteln("'", typeid(T), "' is not Foo or Bar.");
>> }
>
> I like it. The else clause could perform arbitrary checks to make the error
> message as helpful as possible.
I can see it work for the single template case (i've used ctfe'd functions just
for the
error messages like that), but what if there are several spam()s with different
constraints?
The else clauses only get run when no match is found?
artur