可以使用using为数组键入别名吗? [英] Can using be used to type alias an array?
本文介绍了可以使用using为数组键入别名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不确定我的措词是否正确,因为这有点奇怪。
基本上,我发现了一些类似这样的代码:
I'm not sure I've worded this properly since this is a bit of an odd situation. Basically I've found some code like this:
template<class T>
struct X { typedef T Type; };
template<class T>
struct X<const T[]> { typedef T Type[]; }
我正在更改 typedef $ c当我意识到对于第二个示例似乎不起作用时,$ c> s使用
类型别名语法使用C ++ 11 。
And I was in the process of changing the typedef
s to use the C++11 using
type-alias syntax when I realised this doesn't seem to work for the second example.
即
template<class T>
struct X<const T[]> { using Type[] = T; }
为什么?这是标准委员会的监督吗?
Why is this? Is this an 'oversight' by the standards comittee?
推荐答案
正确的语法是:
using Type = T[];
定义 Type
的类型为 T
的未知范围数组。
which defines that Type
has the type "array of unknown bound of T
".
这篇关于可以使用using为数组键入别名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文