Template Inheritance

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 31 01:25:15 PDT 2016


On Sunday, 31 July 2016 at 03:04:27 UTC, Gorge Jingale wrote:
> I like to build structures using template mixins because one 
> can pick and choose functionality at compile time, but still 
> have a relationship between different types.
>
> It would be really nice if one could sort of test if a template 
> mixin was "mixed" in(or ideally, struct S : SomeTemplate 
> (template inheritance)).
>
> While one can overcome a lot of the issues by doing static 
> checking(e.g., does IsSomeTemplate compile or other 
> introspective like checks), it is a bit messy and clutters up 
> the code.
>
> Does anyone do stuff like this and have a nice elegant way?

I suppose you could have the template mixin define a unique key ( 
kinda like the current(?) std.random's isUniformRandom trick) for 
that mixin and then do 
is(hasMember!(S,someUniqueTemplateMixinName))




More information about the Digitalmars-d-learn mailing list