How to write a counterpart to C++ std::invoke that works with both free functions and methods?

60rntogo 60rntogo at
Sun Sep 27 05:22:36 UTC 2020

On Saturday, 26 September 2020 at 23:23:13 UTC, Adam D. Ruppe 
> As a result, you `add` works fine

I'm afraid not. __traits(isStaticFunction, add) is false, I think 
it's because it checks if it is a static member function of some 
struct/class. How would I check if it is actually a free 
function? I tried

isAggregateType!(__traits(parent, add))

but this doesn't even compile since I defined add inside my main 
function and __traits(parent, add) evaluates to main, but 
isAggregateType expects a type as an argument.

More information about the Digitalmars-d-learn mailing list