gcc:g++;与模板朋友打官僚主义

gcc:g++;与模板朋友打官僚主义,gcc,c++11,friend,crtp,function-template,Gcc,C++11,Friend,Crtp,Function Template,在标题视图.h中: template<class S, template<typename> class V> void Operate(S c, const V<S>& vx); template<class T, template<typename> class U> class ViewBase { template<class S, template<typename> class V>

在标题视图.h中:

template<class S, template<typename> class V>
void Operate(S c, const V<S>& vx);

template<class T, template<typename> class U>
class ViewBase
{
    template<class S, template<typename> class V>
    friend void Operate(S c, const V<S>& vx);
};

template<class T>
class ViewTypeA : public ViewBase<T, ViewTypeA>
{

};

template<class T>
class ViewTypeB : public ViewBase<T, ViewTypeB>
{

};

template<class S, template<typename> class V>
void Operate(S c, const V<S>& vx)
{

}
模板
无效操作(S c、常数V和vx);
模板
类视图库
{
模板
朋友无效操作(SC、常数V和vx);
};
模板
类ViewTypeA:公共ViewBase
{
};
模板
类ViewTypeB:公共ViewBase
{
};
模板
无效操作(S c、常数V和vx)
{
}
在cpp中:

#include "view.h"

int main(int argc, char **argv)
{
    Operate(5, ViewTypeA<int>());
    Operate(5, ViewTypeB<int>());
}
#包括“view.h”
int main(int argc,字符**argv)
{
操作(5,ViewTypeA());
操作(5,ViewTypeB());
}
gcc(使用-std=gnu++11编译)给出错误:

Build: Debug in codeblocks (compiler: GNU GCC Compiler) main.cpp||In function ‘int main(int, char**)’: main.cpp|7|error: call of overloaded ‘Operate(int, ViewTypeA&)’ is ambiguous main.cpp|7|note: candidates are: view.h|25|note: void Operate(S, const V&) [with S = int; V = ViewTypeA] view.h|9|note: void Operate(S, const V&) [with S = int; V = ViewTypeA; T = int; U = ViewTypeA] 编译:在代码块中调试(编译器:GNU GCC编译器) main.cpp | |在函数“int main(int,char**)”中: main.cpp | 7 |错误:重载“Operate(int,ViewTypeA&)”的调用不明确 main.cpp | 7 |注:候选人包括: view.h | 25 |注:无效操作(S,const V&)[带S=int;V=ViewTypeA] view.h | 9 |注:无效操作(S,const V&)[带S=int;V=ViewTypeA;T=int;U=ViewTypeA]
main.cpp | 8 |错误:重载“Operate(int,ViewTypeB)”的调用不明确 main.cpp | 8 |注:候选人包括: view.h | 25 |注:无效操作(S,const V&)[带S=int;V=ViewTypeB] view.h | 9 |注:无效操作(S,const V&)[带S=int;V=ViewTypeB;T=int;U=ViewTypeA]
生成失败:2个错误,0个警告(0分钟,0秒)) 问题:
类模板参数根本不应该出现在图片中-我说的对吗?模棱两可似乎是基于类的模板参数。

问题是…?请注意,我已经编辑了我的帖子,使其更短。我的问题是:类模板参数根本不应该出现在图片中-我说得对吗。这种模糊性似乎是基于classClang的模板参数,Intel和Oracle都接受它,所以请向GCC的bugzilla报告。感谢您的回复。我已经提交了gcc bugzilla: main.cpp|8|error: call of overloaded ‘Operate(int, ViewTypeB)’ is ambiguous main.cpp|8|note: candidates are: view.h|25|note: void Operate(S, const V&) [with S = int; V = ViewTypeB] view.h|9|note: void Operate(S, const V&) [with S = int; V = ViewTypeB; T = int; U = ViewTypeA] Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s))