我只是好奇为什么它是用 using 指令这样设计的。对于 1) struct 被视为命名空间,对于 2) 它不是:
struct foo
{
using type0 = int;
};
namespace bar
{
using type1 = int;
}
using bar::type1;
using type0 = foo::type0; // 1)
using foo::type0; // 2)
clang version 3.3 (branches/release_33 186829)
clang -std=c++11 test.cpp
test.cpp:13:12: error: using declaration can not refer to class member
using foo::type0;
~~~~~^
gcc version 4.8.1
c++ -std=c++11 test.cpp
test.cpp:13:12: error: ‘foo’ is not a namespace
using foo::type0;