[英]“multiple template parameter lists are not allowed”?
I'm coding a simple class to manage some code detours. 我正在编写一个简单的类来管理一些代码绕行。
The class: 班级:
class CDetourManager {
public:
CDetourManager() {}
~CDetourManager() {}
template<convention_type tp, typename retn, typename ...args>
VOID AddDetour( Detour<tp, retn, args...>* d ) {
m_Detours.push_back( d );
}
private:
template<convention_type tp, typename retn, typename ...args>
std::vector<Detour<tp, retn, args...>* > m_Detours;
};
But im getting a error: 但是我收到一个错误:
Error 1 error C3857: 'CDetourManager::m_Detours': multiple template parameter lists are not
allowed Error 1 error C3857: 'CDetourManager::m_Detours': multiple template parameter lists are not
不允许使用Error 1 error C3857: 'CDetourManager::m_Detours': multiple template parameter lists are not
Does anyone know what I could do to get rid of that error? 有谁知道我该怎么做才能消除该错误? It's my first time using templates so I'm kind of lost here :(
这是我第一次使用模板,所以我有点迷失在这里:(
It seems that you want to store a vector
of pointers to Detour
s. 似乎您想存储指向
Detour
的指针的vector
。 Since each specialisation of Detour
has a different (and unrelated) type, this is not possible directly. 由于
Detour
每个专业化都有不同(且不相关)的类型,因此这不可能直接实现。 However, if you make the Detour
template inherit from some IDetour
interface which provides the required functions to operate on a Detour
, then you can write AddDetour
as: 但是,如果使
Detour
模板继承自某个IDetour
接口,该接口提供了在Detour
上运行所需的功能,则可以将AddDetour
编写为:
void AddDetour(IDetour *d) {
m_Detours.push_back(d);
}
and m_Detours
as: 和
m_Detours
为:
std::vector<IDetour *> m_Detours;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.