简体   繁体   English

C ++ 11中专用模板的名称别名

[英]Name alias for a specialized template in C++ 11

I'm doing this: 我正在这样做:

template<typename Elem, int D1=1, int D2=1, int D3=1> class matrix;

And have a specialization: 并具有专长:

template<typename Elem> class matrix<Elem, 1, 1, 1>;

Now, I want to get an alias of the specialized template, like this: 现在,我想获得专用模板的别名,如下所示:

template<typename Elem> class scalar;

Since it has a template parameter Elem, typedef seems don't work. 由于它具有模板参数Elem,因此typedef似乎不起作用。 And I don't want to derive the new scalar class from matrix < Elem,1,1,1>... Can I achieve this? 而且我不想从矩阵<Elem,1,1,1>派生新的标量类。我能做到这一点吗? Many thanks. 非常感谢。

You can use a using alias: 您可以使用using别名:

template<class Elem>
using scalar = matrix<Elem, 1, 1, 1>;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM