mixin template hide

arturg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 24 12:19:05 PDT 2016


On Sunday, 24 July 2016 at 18:38:53 UTC, Eppason wrote:

>
> The obvious solution is to refactor Bar, but in the real world, 
> it is much harder and life would be much easier if I could 
> remove foo from exists inside S. At worse, if Bar did depend on 
> foo, I would simply get errors about missing foo.
>
> I doubt it is possible, but maybe some tricks?

you could define a flag for foo, like:

mixin template BAR(bool addFoo = true)
{
     mixin FOO;

     static if(addFoo)
     {
         void foo(){}
     }
}



More information about the Digitalmars-d-learn mailing list