c++ - how to fetch and assign a list of strings which are values of map -
below mentioned map, stored list of string based on string key.
std::map<std::string, std::list<std::string>>mapheadertofields; list<string> strlist;
now return list, , assign return list newly created list variable. how can that?
i tried achieve using below mentioned code snippet. but,i couldn't able assign list. suggestions on how approach on problem.
for (iteheadertofield = mapheadertofields.begin(); iteheadertofield != mapheadertofields.end(); iteheadertofield++) { cout << "key :" << iteheadertofield->first<<endl; strlist.assign((iteheadertofield->second.begin(),(iteheadertofield->second.end()); ((_mapheadertofields.find((iteheadertofield)->first))); }
i tried fetch second element map , assigned list.but, couldn't able assign list. compiler throwing error when assigned list.
is there other way can make it?
you can use std::list
's copy assignment operator
strlist = iteheadertofield->second;
this copy list pointed iterator second element strlist
.
Comments
Post a Comment