从boost无序映射中移除特定密钥

remove specific keys from boost unordered_map

本文关键字:密钥 boost 无序 映射      更新时间:2023-10-16

我有一个boost无序映射容器(mymap(,我想删除一些键,预测器会为它们返回true。

boost::range::remove_if(mymap, ((boost::bind(&mesh::type, (boost::bind(&map_type::value_type::first, _1)))) == EDGE) );

网格::类型定义如下:

class mesh
{
  ...
  Type type() const;
  ...
}

"EDGE"是"类型枚举"之一。

这是我得到的错误:

error: non-static const member ‘const mesh std::pair<const mesh, std::vector<std::vector<Point> > >::first’, can’t use default assignment operator

我使用的是增强版本1.53和C++03。

// define this, either as a static member function or in a 
// private namespace...
bool is_edge(const map_type::value_type& vt)
{
  // note: concerned with the key, not the data
  return vt.first.type() == EDGE;
}
// ... and avoid all the unreadable bind nastiness completely
boost::range::remove_if(mymap, is_edge);