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

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方法like the answer here是否有某种类似的static魔术?
  • 问题FrameData<Projection>是问题吗?还没有完全定义吗?

  • 从技术上讲,这个世界上的其他任何地方都在源文件中,底部带有一些显式实例化,但是我将所有这些都放入一个文件中,并且存在相同的错误。感谢您的任何见解,请不要在非标题模板上羞辱我。这不是我的选择。

    最佳答案



    是。

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

    10-08 16:11