0
我想在地图中插入一个值,其中映射的键是字符串,值是列表。 当我尝试插入时,我收到错误。如何在C++ map中插入值std :: map <string,在C++中列出<string>?
#include <iostream>
#include <utility>
#include <vector>
#include <map>
#include <string>
using namespace std;
main()
{
string key = "myKey";
string str1 = "str1";
map<string, list<string>> myMap;
myMap.insert(make_pair (key, str1));
}
错误
错误2错误C2664: '的std ::对< _Ty1,_Ty2>的std :: _树< _Traits> ::插入(标准::对& &)': 不能转换参数1从 '的std ::对< _Ty1,_Ty2>' 到 '的std ::对< _Ty1,_Ty2> & &'
帮助理解!!
注意'std :: map'是在C++之前引入的11 –
为什么不使用'multimap'或'unordered_multimap'? – Ajay