模板表达式和 Visual Studio 2005 c++
我想用我的 Visual Studio 2005 编译器构建 olb3d 库,但由于模板错误而失败。
更具体地说,以下表达式似乎是一个问题:
void function(T u[Lattice<T>::d])
在该项目的网站上指出,我的编译器可能无法处理如此复杂的模板表达式 - 应该使用 gcc 3.4.1。
我现在的问题是,是否有办法升级我的 vs c++ 编译器,以便它可以像 gcc 3.4.1 一样处理模板表达式?如果我获得更新版本的 Visual Studio,也许会有帮助?
干杯 C.
I'd like to build the olb3d library with my visual studio 2005 compiler but this failes due to template errors.
To be more specific, the following expression seem to be a problem:
void function(T u[Lattice<T>::d])
On the website of the project is stated that prpably my compiler is not capable of such complicated template expressions - one should use the gcc 3.4.1.
My question is now if there is a way to upgrade my vs c++ compiler so it can handle template expressions on the level as the gcc 3.4.1? Maybe it helps if I get a newer version of visual studio?
Cheers
C.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
购买较新版本的 Visual Studio。 2005年已经很老了,不太符合要求。您始终可以先下载 Visual C++ Express 来测试新版本。
Buy a newer version of Visual Studio. 2005 is quite old and not very conformant. You can always test the new one first by downloading Visual C++ Express.
编译器说它无法推断出模板类型。您始终可以通过在代码中指定类型本身来帮助解决这个问题。
然而,
[]
之间的部分是完全没有意义的。数组会退化为指针,并且该值首先被忽略。如果这是一个真实的例子,你可以注释掉该部分。如果您通过引用获取数组,VC++2005 似乎也没有任何问题:(
是否有可能未编译的情况毫无意义,以至于没有人费心检查是否存在喜欢那个工作吗?)
The compiler says that it cannot deduce the template type. You can always help it out by specifying the type itself in your code.
However, the part between
[]
that is tripping it up is completely meaningless. Arrays decay into pointers and the value is ignored in the first place. You can just comment out that part if this is a real example.If you take the array by reference, VC++2005 doesn't appear to have any problem with it either:
(Is it possible that the case that doesn't compile is just so meaningless that no-one ever bothered to check if things like that work?)