【发布时间】:2016-07-12 07:09:48
【问题描述】:
考虑这段代码:
using type = long;
namespace n {
using type = long;
}
using namespace n;
int main() {
type t;
}
这在Clang 3.7 和GCC 5.3 上编译干净,但MSVC 19* 给出以下错误消息:
main.cpp(9): error C2872: 'type': ambiguous symbol
main.cpp(1): note: could be 'long type'
main.cpp(4): note: or 'n::type'
这段代码格式正确吗?标准的哪一部分说明是否在歧义检查之前解析了别名?
请注意,如果您更改其中一个别名,Clang 和 GCC 都会给 MSVC 带来类似的错误。
我完全知道限定名称将如何解决歧义,我只是对标准对此有何规定感兴趣。
*- 只需粘贴代码并在该链接处运行它,我不知道是否有带有永久链接的在线 MSVC 编译器
【问题讨论】:
标签: c++ c++11 language-lawyer typedef name-lookup