2017-10-28 62 views
-2

我有这个类:获取特定模板重载方法指针

class A{ 
    template<typename Type = int32_t> Type b(){} 
    template<typename Type = int32_t> Type b(Type a, Type b){} 
} 

而且我想获得一个指针的函数b<int>()b<int>(int, int)

我试过,但它不知道哪个一个接:

auto t = (void (A::*)(int,int))(&A::template b<int>); 

回答

0

你只是想:

auto t = static_cast<int(A::*)(int, int)>(&A::b<int>); 

您的代码在修复了一堆其他错误后正常工作。

+0

[Demo](https://wandbox.org/permlink/QNW64SM9RyeQDU2I) –