以下代码在 g++ 和 clang 中正确编译:
template<typename T>
struct foo
{
class iterator;
using bar = foo::iterator;
};
int main() {}
但是 MSVC 2013 给出了以下错误:
foo.cpp(9): error C2061: syntax error : identifier 'iterator'
foo.cpp(10) : see reference to class template instantiation 'foo<T>' being compiled
foo.cpp(9): error C2238: unexpected token(s) preceding ';'
如果我将该行更改为:
using bar = typename foo::iterator;
然后所有三个编译器都成功编译它。原版正确吗?(即这是一个 MSVC 错误,还是 gcc/clang 扩展)