Should this work?

Timon Gehr timon.gehr at gmx.ch
Thu Jan 9 19:03:53 PST 2014


On 01/10/2014 02:19 AM, Brad Anderson wrote:
> On Friday, 10 January 2014 at 00:52:27 UTC, H. S. Teoh wrote:
>>
>> <snip>
>>
>> So to summarize:
>> (1) use sig constraints to define the scope of an overload; and
>> (2) use static if inside the function body (or template body) to enforce
>> type requirements within that scope.
>>
>> This solves the problem of needing the compiler to somehow read your
>> mind and figure out exactly which of the 56 overloads of find() you
>> intended to match but failed to.
>>
>>
>> T
>
> Ok, you've convinced me. I still think highlighting which constraints
> failed should happen but for well implemented modules like those in the
> standard library your approach offers even more helpful and tight error
> messages.

static assert is not a good way to implement custom error messages 
because it also changes the behaviour of the declaration.


More information about the Digitalmars-d mailing list