boost::multi_index and std::map find() and erase()

boost::multi_index and std::map find() and erase()

本文关键字:and multi erase find map boost std index      更新时间:2023-10-16

是否有可能将boost::multi_indexfind()erase()的方法包装起来,得到类似的std::mapfind()erase()的方法?

[from comments:]我有这个方法:

typename container1::const_iterator find(const K& key) const
{
  //typedef typename nth_index<container1,0>::type it; c.get<1>().find(key);
  return (???);
}

我应该在返回语句中写什么??

如果我理解你的问题,你想返回一个索引0迭代器,而查找是用索引1完成的,对吗?使用迭代器投影:

template<typename Container, typename Key>
typename Container::const_iterator find(const Container& c, const Key& key)
{
  return c.project<0>(c.get<1>().find(key));
}