void f() {}
namespace test
{
void f(int) {}
void g() { f(); } // error in gcc 6.2.0
}
int main()
{
test::g();
}
使用 g++ -std=c++1z main.cpp 编译它,输出结果如下:
main.cpp: In function 'void test::g()':
main.cpp:9:4: error: too few arguments to function 'void test::f(int)'
f(); // error in gcc
^
main.cpp:5:6: note: declared here
void f(int) {}
我的编译器是gcc 6.2.0。
为什么gcc会隐藏全局命名空间中的重载函数?这符合C++标准吗?
using Base::foo
。 - Lightness Races in Orbit