gpt4 book ai didi

c++ - 在 unix 中编译 C++ 时嵌套模板参数出错

转载 作者:行者123 更新时间:2023-11-30 03:40:56 25 4
gpt4 key购买 nike

我刚刚在unix中写了一个cpp文件。我有一堆使用嵌套模板参数的代码。例如:

void showAlb(map<string, vector<string>> mapArt, map<string, vector<string>> mapSong, vector<string> artists, int artnumb);

但是我总是报错`

error: ?>?should be ? >?within a nested template argument list

`

 void showAlb(map<string, vector<string>> mapArt, map<string, vector<string>> mapSong, vector<string> artists, int artnumb);`
^

我该如何解决?

最佳答案

在 C++11 之前,嵌套的模板参数必须在两个右尖括号之间有一个空格:

map<string, vector<string> >
// here^

C++11 允许您省略该空格。如果您坚持使用 C++03,只需确保遵循该特定语法规则即可。

关于c++ - 在 unix 中编译 C++ 时嵌套模板参数出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37680769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com