【发布时间】:2015-05-12 03:11:25
【问题描述】:
以下代码编译using both Clang and GCC,即使Foo_t<T>::Bar前面没有typename:
struct Foo {
using Bar = int;
};
template<class...>
using Foo_t = Foo;
template<class T>
void f(){
Foo_t<T>::Bar b; // No typename!
}
int main(){
f<int>();
}
应该编译吗?
【问题讨论】:
-
模板别名在使用时立即被替换,所以代码等价于
template <class T> void f() { Foo::Bar b; },没有依赖名。
标签: c++ templates c++11 language-lawyer