c++ - 为什么 C++“使用 XXX = type”类型别名需要“typename”?
问题描述
声明类型别名时,
using T = XXX;
XXX 只能是一个类型。
如果 XXX 是模板类内部的类型别名,为什么还需要在 XXX 之前包含“typename”?
例如,
template <typename T> struct fred
{
using T2 = T[2];
};
template <typename U> struct mary
{
// why is typename necessary here?
using M2 = typename fred <U>::T2;
// this does not compile, even though type alias must refer to a type
// using M2 = fred <U>::T2;
};
解决方案
推荐阅读
- php - 数量不更新
- angular - 角度不更新组件
- mysql - 如何修复无法在将标头发送到客户端后设置标头?
- javascript - 无法发布/联系 - 但我没有在我的代码中请求该帖子
- php - 在同一页面上使用相同的 gform 两次
- html - 当一个具有背景图像时,两个 div 之间的间隙
- c - ISAPI 扩展
- centos7 - 无法打开程序集“/usr/lib/mono/4.5/xsp2.exe”:没有这样的文件或目录
- android - 尝试在空对象引用上调用虚拟方法“java.lang.String com.tnbdev.ulam.model.Region.getSubregionMark()”
- java - 用标点修改Java字符串中单词的字符,但保留所述标点的位置?