how to properly compare this type?

Steven Schveighoffer schveiguy at gmail.com
Thu Feb 11 19:26:22 UTC 2021


On 2/9/21 6:12 PM, Jack wrote:
> static if(is(typeof(__traits(getMember, A, member)) == string 
> function(string)))

That's not what you want. string function(string) is a *pointer* to a 
function that accepts a string and returns a string.

In addition to getting the overloads (you only get one "b" in the list 
of members), take the address of the overload. This worked for me:

             foreach(overload; __traits(getOverloads, A, member))
             static if(is(typeof(&overload) == string function(string)))
             {
                 arr ~= member;
             }

-Steve


More information about the Digitalmars-d-learn mailing list