Constraints error messages [Was: Re: Constrained Templates]

BCS none at anon.com
Mon Jun 14 19:09:40 PDT 2010


Hello bearophile,

> A syntax like the following allows to add the user-defined error
> messages too, but it's bad looking, so probably something quite better
> can be invented:
> 
> template Foo(T)
> if (condition1) else pragma(msg, "error message1")
> if (condition2) else pragma(msg, "error message2") {
> }

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

template Foo(T) if(cond1!T) else pragma(msg, "a") {}
template Foo(T) if(cond2!T) else pragma(msg, "b") {}

Don't run any of the elses unless all the options fail and then run all of 
them?

-- 
... <IXOYE><





More information about the Digitalmars-d mailing list