digitalmars.D.learn - Template Inheritance
- Gorge Jingale (10/10) Jul 30 2016 I like to build structures using template mixins because one can
- Nicholas Wilson (5/16) Jul 31 2016 I suppose you could have the template mixin define a unique key (
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?
Jul 30 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))
Jul 31 2016