如何获得指向模板类的模板方法的函数指针?



我有一个模板类

template <typename ... _AttributeExtensions>
class SomeServiceProxy
: virtual public SomeService,
virtual public SomeServiceProxyBase,
virtual public _AttributeExtensions... {

具有以下方法:

template <typename ... _AttributeExtensions>
void SomeServiceProxy<_AttributeExtensions...>::subscribeSomething(CommonAPI::CallStatus &_internalCallStatus, DataTypes::OperationStatus &_operationStatus, const CommonAPI::CallInfo *_info) {
delegate_->subscribeSomething(_internalCallStatus, _operationStatus, _info);
}

我正在尝试,但不允许限定名称:

typedef ( DataTypes::OperationStatus) (SomeServiceProxy::*subscribeCall) (void);

是否有任何方法来获得这个方法的函数指针?

你还需要为你的成员函数指针创建一个模板别名。使用"using"而不是typedef允许你这样做。

template<typename... extensions>
class SomeServiceProxy
{
public:
void DoSomething() {};
};
template<typename... extensions>
using DoSomethingFnPtr = void (SomeServiceProxy<extensions...>::*)();
int main()
{
SomeServiceProxy<int, int> proxy;
DoSomethingFnPtr<int,int> memfnptr = &SomeServiceProxy<int, int>::DoSomething;
return 0;
}