模板别名上下文中的模板<>模板<>语法有什么用?
What is template<> template<> syntax in the context of template-alias for?
(这个问题与模板模板参数无关。)
我刚刚发现GCC编译这样的代码
template <typename A, typename B>
struct P {};
template <typename A>
template <typename B>
using Q = P<A, B>;
其中CCD_ 1是双重模板化的名称。
但我不能用这个。当我写Q<short><long>
时,我得到
template_template.cpp:10:5: error: ‘Q<short int>’ is not a template
Q<short><long>{};
^~~~~~~~
template_template.cpp:10:20: error: invalid use of incomplete type ‘Q<short int>’
Q<short><long>{};
^
template_template.cpp:2:8: note: declaration of ‘Q<short int>’
struct P {};
为什么要编译第一个代码段?
是否有语法可以让编译器相信Q<short>
实际上是一个模板?
//GCC 6.3.0
C++14标准在14p1:中说明
模板声明中的声明应
--声明或定义函数、类或变量,或
-定义类模板或嵌套在类模板内的类的成员函数、成员类、成员枚举或静态数据成员,或
--是别名声明
此处,模板声明中的声明版声明,其本身包含 别名声明语法的相关部分是: 模板声明:
:
nbsp nbsp;模板<模板参数列表>声明
别名声明
nbsp nbsp;使用标识符属性说明符seqopt=类型id
其中声明可以是模板声明 别名声明请注意,语法本身接受给定的代码,但上面文本中的附加限制使其无效。
相关文章:
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 呼叫运营商<<临时
- 如何防止clang格式在流运算符调用之间添加换行符<<
- <<操作员在下面的行中工作
- EASTL矢量<向量<int>>连续的
- C - 创建矢量&lt; vector&lt; double&gt;&gt;矩阵具有分配而不是inizializ
- 为什么将此对向量&lt; map&lt; int,int&gt;&gt;中的地图进行更新.失败
- C :对矢量进行排序&lt; struct&gt;(结构有2个整数)基于结构的整数之一
- 明确的专业化“ CheckIntmap&lt;&gt;”实例化
- 什么是模板&lt;&gt;inline bla bla
- 编辑C Qlist&lt; object*&gt; gt;QML代码和一些QML警告中的模型
- eigen :: llt&lt;eigen :: matrixxd&gt;具有不完整的类型
- 错误,包括&lt; ctype&gt;在原子上使用C 11
- std::vector<;uint8_t>;当C++11/14启用时,手动复制而不是调用memcpy
- 如何加入向量&lt; int&gt;到C 中的单个INT
- 是std :: set&lt; std :: future&gt;不可能存在
- 是numeric_limits&lt; int&gt; :: is_modulo从逻辑上矛盾
- opencv 2.4.7在iOS错误背景_segm.hpp #include&lt; list&gt;未找到
- 在修改列表后,std :: list&lt; t&gt; :: end()的值是否会更改
- ///<评论></评论>在Visual Studio中