Adding to a global AliasSeq

Basile B. b2.temp at gmx.com
Fri Aug 18 22:07:43 UTC 2023


On Tuesday, 15 August 2023 at 12:20:54 UTC, repr_man wrote:
> On Tuesday, 15 August 2023 at 07:02:45 UTC, Basile B. wrote:
>> You can add a kind of tag with the mixin, that will allow to 
>> to test if the type supplied to `f` is well a Base implementor:
> Firstly, thank you for your help.  This is probably the best 
> solution.
>
> Secondly, I feel very stupid for not having come up with this 
> by myself.  Would you be willing to explain some of the thought 
> process behind your solution?  Are there any key factors that I 
> should look for in future template-related problems?  Or, if it 
> just comes from experience and seeing this sort of thing 
> repeatedly, that's fair, too.
>
> Thanks, once again!

This is just classic D.

The way this works is tied to overload-sets resolution. You have 
two functions templates, same name, same count of parameters. The 
only way to make both exist in the set is "template constraint", 
one works given certain static conditions, the other not. Also, 
as it's time for the explanations, one thing about that system 
and that you should keep in mind is that it's costly, i.e "can 
cause major slowdown of compilation".


More information about the Digitalmars-d-learn mailing list