simple (I think) eponymous template question ... what is proper idimatic way ?
james.p.leblanc
james.p.leblanc at gmail.com
Tue Aug 17 19:22:54 UTC 2021
On Tuesday, 17 August 2021 at 18:28:53 UTC, Steven Schveighoffer
wrote:
> On 8/17/21 2:11 PM, james.p.leblanc wrote:
>> Evening All,
>>
>
> [Template
> constraints](https://dlang.org/spec/template.html#template_constraints).
>
> -Steve
Dear All,
Thanks! I was aware of, and have used template constraints in
simple ways.
But, I should express my question a bit better:
"... is there a more elegant way to expression these constraints?"
Perhaps by extending Alexandru's "moo" concepts, with a list of
allowed types:
auto moo(T : (int || float || mySpecialStruct )(T myMoo) {•••}
When re-using any such sets, it would be nice to define the set
as follows:
S = (int || float || mySpecialStruct)
and then define "moo" more concisely as:
auto moo(T < S)(T myMoo) {•••}
( where I have used "<" to mean "T is a member of S").
Possible?
Best Regards,
James
More information about the Digitalmars-d-learn
mailing list