【发布时间】:2015-12-30 09:32:57
【问题描述】:
我正在尝试在映射中插入一个值,其中映射的键是字符串,值是列表。 当我尝试插入时,我得到了错误。
#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::pair<_ty1> std::_Tree<_traits>::insert(std::pair &&)' : 无法将参数 1 从 'std::pair<_ty1>' 转换为 'std::pair<_ty1> &&'
感谢您的帮助!
【问题讨论】:
-
注意
std::map在 C++11 之前已经引入 -
为什么不使用
multimap或unordered_multimap?
标签: list c++11 dictionary std-pair