获取特定的模板重载方法指针
Get a specific template overloaded method pointer
我有这个类:
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>);
你只需要:
auto t = static_cast<int(A::*)(int, int)>(&A::b<int>);
你的代码在你修复了一堆其他错误后工作。
相关文章:
- 重载方法的方式会在使用临时调用时生成编译器错误
- 使用模板参数重载C++方法:如何使其适用于模板的子类?
- 从纯虚拟类 (A) 派生的指针无法访问来自纯类 (B) 的重载方法
- 一种优雅或至少可行的方法,用于使用和接受具有重载方法和运算符的不同大小的文字数组常量
- 使用 nullptr 调用重载方法是不明确的
- 具有重载方法的可变参数数据结构
- C++11 重载方法,并转发到唯一方法
- 获取特定的模板重载方法指针
- std::result_of 应用于 const 重载方法
- 重载方法的类接受模板和基类 - 如何默认某个方法
- 推导模板类重载方法的地址会导致"error: expected primary-expression before ‘decltype’"
- C++如何使用按值传递和按引用传递的重载方法
- 具有原始方法参数派生类的 C++ 重载方法参数
- SWIG:在派生类中处理基类重载方法
- 在c++中的赋值运算符重载方法中删除旧的动态分配内存
- C++选择'wrong'默认参数的重载方法
- 重写重载方法会隐藏一些重载
- 在C++中,如何从父类变量的子类调用重载方法
- 所有重载方法的别名
- 使用 SWIG 在重载C++方法中设置类型