我知道标题不是很清楚,但我不知道如何用一句话写下来.所以问题是我想要这样的东西:
void(typeof(this)::*function)(int,int);
Run Code Online (Sandbox Code Playgroud)
我知道这不会起作用但是我在徘徊是否在c ++中存在这个问题的解决方案?
更新:
class MainPage
{
public:
MainPage()
{
void (std::remove_reference<decltype(*this)>::*callback)(int, int) = &MainPage::myFunction;
((*this).*callback)(nullptr,nullptr);
}
~MainPage()
{
}
void myFunction(int a, int b)
{
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
错误C2440:'newline':无法从'MainPage*'转换为'std :: remove_reference <_Ty>*'
错误C2647:'.*':无法在'MainPage'上取消引用'void(__thiscall std :: remove_reference <_Ty> ::*)(int,int)'
是的,使用decltype
:
void (std::remove_reference<decltype(*this)>::type::*function)(int, int);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
372 次 |
最近记录: |