Is auto as a parameter in a regular function a GCC 4.9 extension?
问题 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(); } 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\' . 回答1: Yes, this is an extension. It's likely to be added to C++17 as part of the 'concepts' proposal, I believe. 回答2: This is Concepts Lite speak for template<class T> void foo(T c) { std::cout << c.c_str(); } The auto just