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/