c++ - 模板内的模板 : why "` >>' should be ` > >' within

我知道当我们在另一个模板中使用模板时,我们应该这样写:

vector<pair<int,int> > s;

如果我们写的时候没有空格:

vector<pair<int,int>> s;

我们会得到一个错误:

`>>' should be `> >' within a nested template argument list

我认为这是可以理解的,但我不禁想知道,在什么情况下这真的是模棱两可的?

最佳答案

有时你希望它是>>。考虑

boost::array<int, 1024>>2> x;

在 C++03 中,这成功地解析并创建了一个大小为 256 的数组。

关于c++ - 模板内的模板 : why "` >>' should be ` > >' within a nested template argument list",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6695261/

相关文章:

c++ - 使用 Qt 进行序列化

c++ - 调用函数时切换 "transfer of control bypasses initia

c++ - 是否有用于检测 C++11x 支持的预处理器指令?

c++ - 什么时候需要 "typename"关键字?

c++ - C++ 中的 vector ::size_type

c++ - 复制 std::vector:更喜欢赋值还是 std::copy?

c++ - C中有const吗?

c++ - 如何遍历打包的可变参数模板参数列表?

c++ - C 样式字符串作为模板参数?

c++ - 每个类都应该有一个虚拟析构函数吗?