close
The Wayback Machine - https://web.archive.org/web/20190917030738/https://zh.cppreference.com/w/cpp/experimental/map/erase_if

std::experimental::erase_if (std::map)

来自cppreference.com
定义于头文件 <experimental/map>
template <class Key, class T, class Compare, class Alloc, class Pred>
void erase_if(std::map<Key,T,Compare,Alloc>& c, Pred pred);
(库基础 TS v2)

从容器擦除所有满足谓词 pred 的元素。等价于

for (auto i = c.begin(), last = c.end(); i != last; ) {
  if (pred(*i)) {
    i = c.erase(i);
  } else {
    ++i;
  }
}

目录

[编辑] 参数

c - 要从中擦除的容器
pred - 确定该擦除哪些元素的谓词

[编辑] 复杂度

线性。

[编辑] 示例

[编辑] 参阅

移除满足特定判别标准的元素
(函数模板) [编辑]