【问题标题】:Get a specific template overloaded method pointer获取特定模板的重载方法指针
【发布时间】:2017-10-28 20:44:06
【问题描述】:

我有这门课:

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

我想获得函数b&lt;int&gt;()b&lt;int&gt;(int, int)的指针

我试过了,但它不知道该选哪一个:

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

【问题讨论】:

    标签: c++ templates pointers overloading


    【解决方案1】:

    你只想:

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

    您的代码在您修复了一堆其他错误后仍然有效。

    【讨论】:

      猜你喜欢
      • 2014-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多