| |
| Posted by Inquie in reply to Adam D. Ruppe | PermalinkReply |
|
Inquie
Posted in reply to Adam D. Ruppe
| On Tuesday, 14 March 2017 at 19:43:59 UTC, Adam D. Ruppe wrote:
> On Tuesday, 14 March 2017 at 19:39:26 UTC, Inquie wrote:
>> __traits(allMembers, T);
>
> Try derivedMembers instead.
That doesn't work, unfortunately, probably because of the types I'm using(just returns object.
What I can do is this:
enum isElementOfObject(alias T) = (staticIndexOf!(T, __traits(allMembers, Object)) < 0) ? true : false;
enum isElementOfIDispatch(alias T) = (staticIndexOf!(T, __traits(allMembers, IDispatch)) < 0) ? true : false;
enum membersList = Filter!(isElementOfIDispatch, Filter!(isElementOfObject, __traits(derivedMembers, T)));
It would be nice if instead of having to make a large list of isElementOf____, I could pass the types to the predicate:
enum isElementOf(alias S, alias T) = (staticIndexOf!(T, __traits(allMembers, S)) < 0) ? true : false;
enum membersList = Filter!(isElementOf!Object, __traits(derivedMembers, T)));
and ultimately give a list of objects:
enum membersList = Filter!(isElementOf!(Object, IDispatch), __traits(derivedMembers, T)));
Would be pretty cool if D could do that, but I doubt it can ;/ (not logically impossible, sort of like currying or something)
|