Showing a user specified error message when no overloads match

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 25 00:52:33 PDT 2014


I have a template function with a particular constraint (in this 
case [1]). When this constraint doesn't match, I want to give the 
user a suggestion what to do instead.

The only way I know of to do this currently is to relax the 
template constraints, and adding a `static assert`. However, if 
there is another function that would match, this would lead to an 
ambiguity.

Is there a way to trigger the static assert only if there are no 
other overloads (including members and UFCS functions) that 
match? Or maybe a solution that only works for this particular 
case?

[1] https://github.com/D-Programming-Language/phobos/pull/2350


More information about the Digitalmars-d-learn mailing list