Larry
Larry

Reputation: 175

How to declare a pointer to member template function?

struct S
{
    template <auto> void F(){};
};

S s;
void (S::* pmf)()=s.F<true>;

compiles error, how to fix it? Thanks for your help.

Upvotes: 2

Views: 61

Answers (1)

songyuanyao
songyuanyao

Reputation: 172864

You should use the class name to qualify the member function, and there's no implicit conversion from member function to member function pointer, so use operator& explicitly. e.g.

void (S::* pmf)() = &S::F<true>;

LIVE

Upvotes: 3

Related Questions