Template within template: why quot;`gt;gt;#39; should be `gt; gt;#39; within a nested template argument listquot;(模板中的模板:为什么是“gt;gt;应该是`gt;gt;在嵌套模板参数列表中)
问题描述
我知道当我们在另一个模板中使用模板时,我们应该这样写:
I know that when we are using template inside another template, we should write it like this:
向量<pair<int,int>>s;
如果我们写的时候没有空格:
and if we write it without the whitespace:
向量<pair<int,int>>s;
我们会得到一个错误:
`>>' 应该是嵌套模板参数列表中的 `> >'
`>>' should be `> >' within a nested template argument list
我认为这是可以理解的,但我不禁想知道,在什么情况下这真的是模棱两可的?
I see this is understandable, but I just can't help but wondering, in which cases will this be really ambiguous?
推荐答案
有时你希望它是 >>.考虑
boost::array<int, 1024>>2> x;
在 C++03 中,这成功地解析并创建了一个大小为 256 的数组.
In C++03 this successfully parses and creates an array of size 256.
这篇关于模板中的模板:为什么是“>>"应该是`>>'在嵌套模板参数列表中"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:模板中的模板:为什么是“>>"应该是`>>'在嵌套模板参数列表中"
基础教程推荐
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- c++ STL设置差异 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
