Specialize mixin templates

Timon Gehr timon.gehr at gmx.ch
Sat Aug 11 19:32:29 PDT 2012


On 08/11/2012 11:42 PM, Henning Pohl wrote:
> A struct takes a mixin template as argument:
>
> struct S(alias Mixin) {
> mixin Mixin;
> }
>
>
> How to specialize a mixin template like this one to pass to S?
>
> mixin template MixinTemplate(T) {
> }
>
>
> S(MixinTemplate!float); // Something like this

This is a way to do it:

struct S(alias Mixin){
     mixin Mixin;
}

mixin template MixinTemplate(T){
}
mixin template MixinTemplateFloat(){
     mixin MixinTemplate!float;
}

S!MixinTemplateFloat s;


More information about the Digitalmars-d-learn mailing list