本文介绍了auto 作为常规函数中的参数是 GCC 4.9 扩展吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
gcc 4.9 允许以下代码,但 gcc 4.8 和 clang 3.5.0 拒绝它.
gcc 4.9 allows the following code, but gcc 4.8 and clang 3.5.0 reject it.
void foo(auto c)
{
std::cout << c.c_str();
}
我收到 警告:ISO C++ 禁止在 4.9 中的参数声明 [-Wpedantic]
中使用auto",但在 4.8 和 clang 中我收到 error: parameter declaration 'auto'
代码>.
I get warning: ISO C++ forbids use of 'auto' in parameter declaration [-Wpedantic]
in 4.9 but in 4.8 and clang I get error: parameter declared 'auto'
.
推荐答案
是的,这是一个扩展.我相信,它很可能会作为概念"提案的一部分添加到 C++17 中.
Yes, this is an extension. It's likely to be added to C++17 as part of the 'concepts' proposal, I believe.
这篇关于auto 作为常规函数中的参数是 GCC 4.9 扩展吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!