erase_if在哪里? [英] Where is erase_if?

查看:130
本文介绍了erase_if在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个容器,并希望根据谓词删除元素。 Erase_if听起来很熟悉,但我不能在C ++中找到它。它是什么名字,它在哪里定义?
我想在VS10中使用一个lambda。

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 is it defined? I'd like to use it with a lambda in VS10.

推荐答案

href =http://en.cppreference.com/w/cpp/algorithm/remove> std :: remove_if ,格式如下:

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

这篇关于erase_if在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆