On Thursday, 2 March 2017 at 06:40:29 UTC, Dukc wrote:
If I define an opDispatch for something, but the call does not compile, the compiler currently behaves as if the opDispatch didn't exist at all. Just like C++ templates as far as I know. Why is this? I think it would be better if it acted like other D templates: Compilation failure is always an error, but you can use preconditions if you want the "substitution failure is not an error"-idiom. This would be better to detect errors.

Is there any way to define a dispatching type so that it errs or at least announces if the call does not compile?

All templates have SFINAE.
opDispatch as well.

you can force a compilation error by defining a catch-all overload that static asserts.

Reply via email to