mercredi 12 mai 2021

Unsure about fixing "no matching function for call" error

I am having trouble figuring out an error I'm getting.

Basically, I have an unordered_map, which maps string to int, and I'm trying to return the string using the int:

This is what I wrote:

// for each int representations of neighbor nodes
for(long unsigned int i = 0; i < labels.size(); i++) {
    // return string representation of neighbor nodes
    std::unordered_map<std::string,int>::const_iterator got = umap.find(labels[i]);
    ret.push_back(got->first);
}

Where ret is a vector of strings, labels is a vector of ints, and umap is my unordered_map<string,int>.

The error I am getting is this:

no matching function for call to 'std::unordered_map<std::__cxx11::basic_string<char>, int>::find(__gnu_cxx::__alloc_traits<std::allocator, int>::value_type&)'

Aucun commentaire:

Enregistrer un commentaire