简体   繁体   English

boost :: unordered_map()的find()方法上的问题

[英]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). 此代码使用clang正确编译(在MacO中)。 However, eclipse is alerting that there is a problem in the way the find() method is called. 但是,eclipse会警告find()方法的调用方式存在问题。 More in particular, it alerts that find() is invoked with an incompatible argument by returing the error: 更特别的是,它通过重现错误来警告使用不兼容的参数调用find():

"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 &) '" “无效的参数'候选者是:boost :: unordered :: iterator_detail :: iterator >> find(const unsigned char&)boost :: unordered :: iterator_detail :: c_iterator>,const boost :: unordered :: detail :: ptr_node> *>查找(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. 现在,所有代码都可以正确编译,因此可能是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. 我认为这是日食的错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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