Template within template: why quot;`gt;gt;#39; should be `gt; gt;#39; within a nested template argument listquot;(模板中的模板:为什么是“`应该是`gt;在嵌套的模板参数列表中)
问题描述
我知道当我们在另一个模板中使用模板时,我们应该这样写:
I know that when we are using template inside another template, we should write it like this:
vector
如果我们在没有空格的情况下编写它:
and if we write it without the whitespace:
vector
我们会得到一个错误:
`>>' 应该是嵌套模板参数列表中的 `> >'
`>>' 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.
这篇关于模板中的模板:为什么是“`>"应该是`>>'在嵌套的模板参数列表中"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:模板中的模板:为什么是“`>"应该是`>&a
基础教程推荐
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 这个宏可以转换成函数吗? 2022-01-01
