c++ - 以类为参数调用模板类的静态模板方法

标签 c++ class c++11 templates

static没有问题具有(i)模板和(ii)类本身作为参数的模板类的方法,有吗?考虑类

template<class Projection>
struct FrameData {
    // ...
    template <bool devPtr>
    static void allocate(FrameData<Projection> &data) {
        // ... do allocations ...
    }

}

这是在文件 A 的标题中声明的.在世界的其他地方,我有类似的东西

template <class Projection>
void some_method(FrameData<Projection> &m_data) {
    FrameData<Projection>::allocate<true>(m_data);
}

我要结束了

error: reference to overloaded function could not be resolved; did you mean to call it?
  • 有没有类似的.template static 的魔法方法 like the answer here
  • 是参数FrameData<Projection>问题?还没有完全定义吗?

这个世界的其他地方在技术上是在一个源文件中,底部有一些显式实例化,但我把这些都放在一个文件中,但有同样的错误。感谢您提供任何见解,请不要在非标题模板上羞辱我。这不是我的选择。

最佳答案

Is there some sort of analagous .template magic for static methods like the answer here?

是的。

template <class Projection>
void some_method(FrameData<Projection> &m_data) {
    FrameData<Projection>::template allocate<true>(m_data);
}

关于c++ - 以类为参数调用模板类的静态模板方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44482991/

相关文章:

c++ - 创建双向链表节点的深层拷贝

c++ - 排序子网格/VBO

matlab - 在 MATLAB 中修改决策树的精度

c++ - 在预期下执行的随机森林

java - 将类类型存储为变量以识别 java 列表中下一个预期的对象类型

javascript - 连续的js方法

c++ - notify_all 崩溃后直接删除 std::condition_variable_any

c++ - 动态更改文本 qlabel

c++ - 你如何通过传递 "this"关键字来分配 weak_ptr?

c++ - 将 const int 转换为指针?