【发布时间】:2012-05-17 14:40:22
【问题描述】:
例如 GCC 和 clang 都无法编译如下代码:
struct S {};
namespace N
{
void g(S);
}
using N::g;
namespace N
{
void g(int);
}
int main()
{
g(0);
}
出现错误:
test.cpp: In function 'int main()':
test.cpp:17:8: error: could not convert '0' from 'int' to 'S'
g(0);
^
建议 using-declaration 仅导入在 using-declaration 出现的位置高于声明的重载,而不是稍后可能出现的重载(但在使用名称之前)。
这种行为正确吗?
【问题讨论】:
标签: c++ namespaces scope overloading using-declaration