KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have this class class Point2D { public: bool isValid(); // ... private: double x_, y_; }; I have a std::vector< Point2D > and I would like to remove the invalid points, now I do like this: bool invalid ( const Point2D& p ) { return !p.isValid(); } void f() { std::vector< Point2D > points; // fill points points.erase( std::remove_if( points.begin(), points.end(), invalid ), points.end() ); // use valid points } Is there a standard way of doing this (beautifully), for example without the need of "duplicating" the functionality of the class method Point2D::isValid ? Maybe using C++11 lambda (I am not very familiar with lambda)?
Tags (comma-separated)
Save Edits
Cancel