templates - 错误: 'template' (as a disambiguator) is only allowed within templates

标签 templates gcc

我正在尝试使用当前的 C 编译器编译一些旧代码(大约 2003 年的 robocup 足球模拟服务器):

gcc-c++-4.7.2-2.fc17.x86_64

下面的函数会生成此问题主题中的错误。任何有关如何修改函数以消除错误的建议将不胜感激。

int getInt( const std::string& param ) const
{ return rcss::conf::Builder::template get< int >( param ); }

最佳答案

我假设 Builder 是一个类,而 get 是该类的静态模板方法。

关键字template告诉编译器get是一个模板方法。但是,gcc 表示,如果模板中尚未包含该关键字,则不应使用该关键字。

因此,删除 template 关键字应该可以使其正常工作。

关于templates - 错误: 'template' (as a disambiguator) is only allowed within templates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14288333/

相关文章:

templates - 是否可以在 Julia 中声明对任何结构的一般引用?

c++ - Pthread 模板参数错误

javascript - 在 javascript 中使用 handlebars 模板变量

gcc - 我如何使用 objdump 之类的东西判断目标文件是否是使用 -fPIC 构建的?

c++ - 使用 GCC (G++) 编译 c++ OpenACC 并行 CPU 代码

c++ - 为什么下面的代码使用 clang 而不是 gcc 编译

c++ - std::function 类型和模板实例化

c++ - C++ 中的函数模板,两个问题

gcc - 如何将源代码目录添加到 gcc 的搜索路径?

c++ - 本地结构通过使用通用模板函数影响不同的翻译单元