我有GetContainer()函数如下.
template<typename I,typename T,typename Container>
Container& ObjCollection<I,T,Container>::GetContainer()
{
return mContainer;
}
Run Code Online (Sandbox Code Playgroud)
当我使用这个方法如下
template<typename I,typename T>
T& DynamicObjCollection<I,T>::Insert(T& t)
{
GetContainer().insert(&t);
return t;
}
Run Code Online (Sandbox Code Playgroud)
我有错误.
error: there are no arguments to ‘GetContainer’ that depend on a template parameter,
so a declaration of ‘GetContainer’ must be available
error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of
an undeclared name is deprecated)
Run Code Online (Sandbox Code Playgroud)
它适用于MSVC,但g ++不是那么宽容.代码有什么问题?