Get list of public methods of struct
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 9 11:02:02 PST 2017
On Thursday, March 09, 2017 18:48:22 Adam D. Ruppe via Digitalmars-d-learn
wrote:
> On Thursday, 9 March 2017 at 18:32:41 UTC, tcak wrote:
> > Is there any way to get list of public methods of a struct?
>
> You can loop through __traits(allMembers, YourStruct) and check
> protection, type, etc.
>
> __traits(getMember, YourStruct, "some name") gets one method in
> particular. allMembers returns a list of name strings.
If there's any risk of the same function name being used for both public and
private functions, then __traits(getOverloads, ...) is going to need to be
used rather than getMember, since getMember only gives you one of the
overloads.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list