Given an object, how to call an alias to a member function on it?

Steven Schveighoffer schveiguy at gmail.com
Tue May 2 13:57:23 UTC 2023


On 5/2/23 8:52 AM, Quirin Schroll wrote:
> How do I invoke the member function in a reliable way? Given `obj` of 
> the type of the object, I used `mixin("obj.", __traits(identifier, 
> memberFunc), "(params)")`, but that has issues, among probably others, 
> definitely with visibility. (The member function alias is a template 
> parameter.)

Isn't that what `__traits(child)` is for?

https://dlang.org/spec/traits.html#child

-Steve


More information about the Digitalmars-d-learn mailing list