嵌套 class 模板类型别名

Nested class template type alias

这可能是一个简单的问题,但我似乎无法弄清楚为嵌套 class 模板定义类型别名的语法。

基本上,我有:

template<class T>
struct Outer {
    template<class U = T>
    struct Inner {};
}

我希望能够从 class 定义之外访问作为类型的内部 class。 我试过:

template<class T> 
using Inner = typename Outer<T>::Inner;

template<class T, class U = T> 
using Inner = typename Outer<T>::Inner<U>;

但这没有用。

实际应该怎么做?

你需要额外的 template:

template<class T, class U = T> 
using Inner = typename Outer<T>::template Inner<U>;

Demo