Scope of Mixins
Adam D Ruppe
destructionator at gmail.com
Thu Aug 26 18:15:38 UTC 2021
On Thursday, 26 August 2021 at 18:07:48 UTC, Ali Çehreli wrote:
> In some cases it's more useful to have a 'static if' inside a
> single function template instead of two separate function
> templates.
In most cases that's better. A template constraint is really a
way to say "this template cannot accept this". When you use it to
overload, the conditions get ugly fast since you need to make
sure they're all mutually exclusive and the error messages get
wrong since the compiler isn't sure if the thing can or can't be
accepted.
What you generally want to do here is if the call - from the
user's perspective - should work, make sure it gets through the
constraint. Then do the details of branches inside.
More information about the Digitalmars-d-learn
mailing list