2017-10-28 95 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) –