简体   繁体   中英

problems on the find() method of boost::unordered_map()

I have the following code:

typedef unsigned char tTerm;
typedef uint64_t nTerm;

boost::unordered_map<tTerm *, nTerm> map;

nTerm function(tTerm * key) {
  boost::unordered_map<tTerm *, nTerm>::iterator it = standardTerms.find(key);
    if (it != standardTerms.end()) {
      return it->second;
  }
}

This code compiles correctly using clang (in MacOs). However, eclipse is alerting that there is a problem in the way the find() method is called. More in particular, it alerts that find() is invoked with an incompatible argument by returing the error:

"Invalid arguments ' Candidates are: boost::unordered::iterator_detail::iterator>> find(const unsigned char &) boost::unordered::iterator_detail::c_iterator>,const boost::unordered::detail::ptr_node> *> find(const unsigned char &) boost::unordered::iterator_detail::iterator>> find(const #10000 &, const #10001 &, const #10002 &) boost::unordered::iterator_detail::c_iterator>,const boost::unordered::detail::ptr_node> *> find(const #10000 &, const #10001 &, const #10002 &) '"

Now all the code compiles correctly, so it might be that it's an eclipse bug. However, I might be missing something important by ignoring this message. What do you think?

Nothing to worry. Looks correct to me. You can use pointers as keys. I think it's eclipse's fault.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM