I have an std::map. and I would like to iterate over it and use the result as an argument to a function. The compilation seems to complain about my object beeing a lvalue, but I cannot figure out why it is considered as a lvalue.
void my_function(std::pair<std::string, std::string>& my_arg){
//do stuff, modify elements from the pair
}
std::map<std::string, std::string> my_map;
// fill the map with values...
for(auto& element : my_map){
my_function(element);
}
I could probably use an iterator to solve this, but I would like to learn how to do it the c++11 way.
Thanks
Aucun commentaire:
Enregistrer un commentaire