simple (I think) eponymous template question ... what is proper idimatic way ?

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Tue Aug 17 18:21:25 UTC 2021


On Tuesday, 17 August 2021 at 18:11:56 UTC, james.p.leblanc wrote:
> Is there a more elegant way, to do this?
>
> Regards,
> James
>
> PS Any violations should be caught at compile time.

That is template specialization:

```
auto moo(T : YourSpecialClassOrDType)(T myMoo) {•••}
```

You can also declare other overloads of the method, just make 
sure they don't overlap in the constraints, otherwise you'd get 
ambiguous call exception.

Regards,
Alexandru.


More information about the Digitalmars-d-learn mailing list