Remove stuff from a template mixin

Gorge Jingale via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 26 12:00:07 PDT 2016


Is there a way to remove functions and fields that a mixin 
template adds?

I use mixin templates to create other types contents, like

struct A { mixin Stuff(); }

But Sometimes I only want some of the stuff.

struct B { mixin Stuff(); @disable Add(); }

B is like an A but doesn't have the ability to add.

While I could do something like move the Add function to another 
template, it gets messy quickly because all I want to do is 
remove a feature, not create a hierarchical system like oop.

I tried making add private, but b.Add() still calls Stuff.Add.



More information about the Digitalmars-d-learn mailing list