假设以下代码:
namespace test
{
namespace detail
{
}
inline namespace v1
{
namespace detail
{
void foo()
{
}
}
}
}
int main()
{
test::detail::foo();
}
正如我们所见,这段代码是用 Clang 编译的;不是GCC,但是 - GCC 抱怨引用namespace detail
是模棱两可的:
main.cpp:20:11: error: reference to 'detail' is ambiguous
test::detail::foo();
^
main.cpp:4:5: note: candidates are: namespace test::detail { }
{
^
main.cpp:10:9: note: namespace test::v1::detail { }
{
^
哪个编译器在这里做正确的事情?