mercredi 30 décembre 2015

How to insert value in c++ map std::map

I am trying to insert a value in map where key to map is string and value is list. When I try to insert then I am getting error.

#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));

 }

error

Error 2 error C2664: 'std::pair<_Ty1,_Ty2> std::_Tree<_Traits>::insert(std::pair &&)' : cannot convert parameter 1 from 'std::pair<_Ty1,_Ty2>' to 'std::pair<_Ty1,_Ty2> &&'

Help is appreciated !!

Aucun commentaire:

Enregistrer un commentaire