[flat.set.erasure] # 23 Containers library [[containers]](./#containers) ## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.set.erasure) ### 23.6.11 Class template flat_set [[flat.set]](flat.set#erasure) #### 23.6.11.6 Erasure [flat.set.erasure] [🔗](#lib:erase_if,flat_set) `template constexpr typename flat_set::size_type erase_if(flat_set& c, Predicate pred); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19444) *Preconditions*: Key meets the *Cpp17MoveAssignable* requirements[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19448) *Effects*: Let E be bool(pred(as_const(e)))[.](#2.sentence-1) Erases all elements e in c for which E holds[.](#2.sentence-2) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19453) *Returns*: The number of elements erased[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19457) *Complexity*: Exactly c.size() applications of the predicate[.](#4.sentence-1) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19461) *Remarks*: Stable ([[algorithm.stable]](algorithm.stable "16.4.6.8 Requirements for stable algorithms"))[.](#5.sentence-1) If an invocation of erase_if exits via an exception,c is in a valid but unspecified state ([[defns.valid]](defns.valid "3.67 valid but unspecified state"))[.](#5.sentence-2) [*Note [1](#note-1)*: c still meets its invariants, but can be empty[.](#5.sentence-3) — *end note*]