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

时间:2011-12-03 16:55:44

标签: c++ boost c++11

可以包装boost::multi_index find()erase()方法以获取类似的std::map find()erase()方法吗?

[来自评论:]我有这个方法:

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

我应该在退货声明中写什么?

1 个答案:

答案 0 :(得分:1)

如果我理解你的问题,你想要返回一个index-0迭代器,而查找是用索引1完成的,对吧?使用iterator projection

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