Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ gcc模板类<;::全球符号>;<;上出现错误::_C++_Templates_Gcc - Fatal编程技术网

C++ gcc模板类<;::全球符号>;<;上出现错误::

C++ gcc模板类<;::全球符号>;<;上出现错误::,c++,templates,gcc,C++,Templates,Gcc,由于某些原因,gcc不喜欢模板参数是全局名称空间符号,即 TemplateClass<::GlobalSymbol> 不管怎样,我接受了帮助我找到答案的答案。使用gcc 4.6,我得到以下错误: graphs.cpp: In function ‘int main()’: graphs.cpp:9:15: error: ‘<::’ cannot begin a template-argument list [-fpermissive] graphs.cpp:9:15: note

由于某些原因,gcc不喜欢模板参数是全局名称空间符号,即

TemplateClass<::GlobalSymbol>

不管怎样,我接受了帮助我找到答案的答案。

使用gcc 4.6,我得到以下错误:

graphs.cpp: In function ‘int main()’:
graphs.cpp:9:15: error: ‘<::’ cannot begin a template-argument list [-fpermissive]
graphs.cpp:9:15: note: ‘<:’ is an alternate spelling for ‘[’. Insert whitespace between ‘<’ and ‘::’
graphs.cpp:9:15: note: (if you use ‘-fpermissive’ G++ will accept your code)

或者类似的东西,例如python。但是,只有当你确信你从未使用过@queen3时,你才知道解决方法:separate
确切的名称是“alternative token”,因为它们并不都是有向图(而且你链接到的Wiki文章特别糟糕)。至于解决方法,您已经找到了:只需在
vector
中的代码>>
引入了一个特殊的重写规则;也许这个案例也应该有一个规则。)@queen3:对不起,我没有注意到你不想第一次修改源代码。无论如何都已更新答案的完整性。是否要在源代码中修复它?Pragma是源文件的一部分。是的,但是我可以将自动生成的源文件包含到另一个文件中,并用Pragma包装include。我可以考虑编译带有自动许可的自动生成文件,但是CGOLE不允许每个文件CXX标志,只有每个模块。
 #pragma GCC diagnostic ignored "-fpermissive"
test.cpp:9:16: note: (if you use ‘-fpermissive’ G++ will accept your code)
graphs.cpp: In function ‘int main()’:
graphs.cpp:9:15: error: ‘<::’ cannot begin a template-argument list [-fpermissive]
graphs.cpp:9:15: note: ‘<:’ is an alternate spelling for ‘[’. Insert whitespace between ‘<’ and ‘::’
graphs.cpp:9:15: note: (if you use ‘-fpermissive’ G++ will accept your code)
sed -i 's,<::,< ::,g' filename.cpp