我不明白这个C++错误 - 错误C2101:'&'常量

mar*_*hon 5 c++ templates compiler-errors visual-c++

这个代码应该适用于GCC - 我试图让它与Visual Studio一起工作.我无法弄清楚代码是否真的有问题,或者我没有对端口做正确的事情.

1>c:\somepath\aaa.h(52): error C2101: '&' on constant
1>          c:\somepath\aaa.h(52): while compiling class template member function 'const blahblah::Message something::AClass<Type>::aMethod(void) const'
1>          with
1>          [
1>              Type=const lala::BClass&
1>          ]
1>          c:\somepath\bbb.h(79) : see reference to class template instantiation 'something:AClass<Type>' being compiled
1>          with
1>          [
1>              Type=const lala::BClass&
1>          ]
1>  MyApplication.cpp
Run Code Online (Sandbox Code Playgroud)

aaa.h:52          virtual const Type aMethod() const { return Type(); }

bbb.h:79          AClass<const BClass&> blahblahblah_;
Run Code Online (Sandbox Code Playgroud)

ser*_*rvn 8

构造T()T是引用类型的地方是无效的,没有任何意义.某些版本的gcc错误地接受了它.