C++ 获取特定的模板重载方法指针
我有这门课:C++ 获取特定的模板重载方法指针,c++,templates,pointers,overloading,C++,Templates,Pointers,Overloading,我有这门课: class A{ template<typename Type = int32_t> Type b(){} template<typename Type = int32_t> Type b(Type a, Type b){} } A类{ 模板类型b(){} 模板类型b(类型a,类型b){} } 我想得到函数b()和b(int,int) 我试过这个,但它不知道该选哪一个: auto t = (void (A::*)(int,int))(&a
class A{
template<typename Type = int32_t> Type b(){}
template<typename Type = int32_t> Type b(Type a, Type b){}
}
A类{
模板类型b(){}
模板类型b(类型a,类型b){}
}
我想得到函数b()
和b(int,int)
我试过这个,但它不知道该选哪一个:
auto t = (void (A::*)(int,int))(&A::template b<int>);
autot=(void(A::*)(int,int))(&A::模板b);
您只需要:
auto t = static_cast<int(A::*)(int, int)>(&A::b<int>);
auto t=static\u cast(&A::b);
您的代码在修复了一系列其他错误后仍能正常工作