Remove stuff from a template mixin

Jerry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 26 15:23:37 PDT 2016


On Tuesday, 26 July 2016 at 19:02:32 UTC, Gorge Jingale wrote:
> I might want to actually use Add internally in B so I can add 
> some elements behind the scenes, I do not want to expose it to 
> the outside world though.

There are no way to remove things from an template directly. But 
you could however generate a new type which does not carry the 
specified members.

This requires two steps:
*The member filtering part
*Generation part

For the masking part take a look at
https://forum.dlang.org/post/nn8gj8$6s5$1@digitalmars.com

What you basicly do is that you iterate the members and based on 
some condition filters out the members you don't want.

Then for generating you have to handle functions and fields.
For fields a string concatenated with other strings fields is 
probably good enough.
Something like this:
      "typeof(" ~ fullyQualifiedName!Aggregate ~ "." ~ memberName 
~ ") " ~ member;"




More information about the Digitalmars-d-learn mailing list