当 C++ 标准引入语法"vector<vector<int>>"(即最终">>")的假设时?

when c++ standard introduces the suppose of the syntax `vector<vector<int>>` (i.e. `>>` in the end?

本文关键字:gt lt vector 假设 int 语法 C++ 标准      更新时间:2023-10-16
include <vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    vector<vector<int>> vecVecInts;
    return 0;
}

我已经关闭了Visual Studio 2008语言扩展,并在没有警告或错误的情况下编译了上面的代码。

我曾经记得我们必须替换以下行

vector<vector<int>>

vector<vector<int> >

因为当时的编译器最终无法识别>>

问题>C++标准什么时候引入这种语法更甜蜜?

谢谢

它是在最新的标准 C++11, §14.2/3 中引入的:

解析模板参数列表时,第一个非嵌套>将作为结束分隔符 而不是大于运算符。同样,第一个非嵌套>>被视为两个连续但 不同的>标记,其中第一个作为模板参数列表的末尾,并完成 模板标识。