Where is erase_if?

后端 未结 6 1274
不思量自难忘°
不思量自难忘° 2021-01-07 20:51

I\'ve got a container and would like to erase elements based on a predicate. erase_if sounds familiar, but I can\'t find it in C++. What\'s the name and where i

6条回答
  •  暖寄归人
    2021-01-07 21:19

    You're probably looking for std::remove_if, in a pattern such as:

    vec.erase(std::remove_if(vec.begin(), vec.end(), predicate), vec.end());
    

提交回复
热议问题