On 8/17/21 2:11 PM, james.p.leblanc wrote:
Evening All,
Eponymous templates allow a nice calling syntax. For example, "foo"
here can
be called without needing the exclamation mark (!) at calling sites. We
see that
foo is restricting a, and b to be of the same type ... so far, so good.
auto foo(T)(T a, T b) { ... }
Now, suppose I need to restrict "T" only certain subsets of variable types.
I can imagine putting in some "static if" statements in my function body,
is one solution. (Also a bit ugly as the allowed types might grow).
Is there a more elegant way, to do this?
[Template
constraints](https://dlang.org/spec/template.html#template_constraints).
-Steve