簡體   English   中英

如何聲明指向成員模板 function 的指針?

[英]How to declare a pointer to member template function?

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

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

編譯錯誤,如何解決? 謝謝你的幫助。

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. 例如

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

居住

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM