【问题标题】:problems on the find() method of boost::unordered_map()boost::unordered_map() 的 find() 方法的问题
【发布时间】:2013-11-05 07:29:54
【问题描述】:

我有以下代码:

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;
  }
}

此代码使用 clang(在 MacO 中)正确编译。但是,eclipse 警告调用 find() 方法的方式存在问题。更具体地说,它会通过返回错误来提醒 find() 是使用不兼容的参数调用的:

"无效参数的候选者是: 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 &) '"

现在所有代码都可以正确编译,所以可能是 Eclipse 错误。但是,忽略此消息,我可能会遗漏一些重要的东西。你怎么看?

【问题讨论】:

    标签: c++ boost unordered-map


    【解决方案1】:

    没什么好担心的。在我看来是正确的。您可以使用指针作为键。我认为这是eclipse的错。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 2019-11-05
      • 1970-01-01
      • 2011-05-16
      相关资源
      最近更新 更多