I'm trying to use a getter for a field std::unordered_map<std::string, User *> userMap
to find a user in it.
I tired doing:
std::unordered_map<std::string, User *>::const_iterator found = getUserMap().find(userName);
but valgrind detected an invalid read of size 8. However when I did this:
std::unordered_map<std::string, User *> tmpUserMap = getUserMap();
std::unordered_map<std::string, User *>::const_iterator found = tmpUserMap.find(userName);
The invalid read went away.
The getter is a standard getter:
std::unordered_map<std::string, User *> Session::getUserMap() const{
return userMap;
}
If needed I can provide the valgrind data, i'm using c++11 on clion editor.
Aucun commentaire:
Enregistrer un commentaire