如何定义模板的类型别名的一类

问题描述:

例如如何定义模板的类型别名的一类

struct Option_1 
{ 
    template<class T> using Vector = std::vector<T>; 
}; 

我可以做

typename Option_1::Vector<int> v; 

但我更喜欢以下

Vector<Option_1, int> v; 

或同类者,而不单词“typename”。我定义了别名

template<class Option, class T> using Vector= typename Option::Vector<T>; 

但由于无法识别模板声明/定义而失败。如何解决它?

+0

参见:* [在哪里,为什么我必须把“模板”和“类型名”关键词?(http://*.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords)*。 – Pixelchemist

你应该使用关键字template的依赖模板名称Option::Vector,即

template<class Option, class T> using Vector = typename Option::template Vector<T>; 
//                ~~~~~~~~ 

LIVE