I have a following class:
class Foo
{
public:
void Fill();
private:
std::vector<std::wstring> vec;
};
And then the implementation is:
void Foo::Fill()
{
vec.push_back( L"abc aaa" );
vec.push_back( L"def aaa" );
vec.push_back( L"fed bbb" );
vec.push_back( L"cba bbb" );
}
What I'd like to do to delete an element from this vector, lets say one that contains "def". What would be the easiest way to do so?
I'm thinking to use remove_if, but the comparator accept only 1 parameter - container element.
Is there an elegant solution? I'd use looping as a last resort.
remove_ifexpects expects a unary predicate. You can pass a lambda that returns true or false based upon your search.