How to use remove-erase idiom for removing empty vectors in a vector?

I have some trouble with removing a empty vector in a vector using the remove-erase idiom like Erasing elements from a vector. How can I apply this on:

vector<vector<Point> > contours; // want to remove contours.at(i).empty() contours.erase(remove(contours.begin(), contours.end(), ??? ),contours.end());


Have you tried:

contours.erase(remove(contours.begin(), contours.end(), vector<Point>()), contours.end());


Use remove_if that takes a predicate.

contours.erase( std::remove_if( contours.begin(), contours.end(), [](const vector<Point>& v) { return v.empty(); } // or a functor/plain function/Boost.Lambda expression ), contours.end() );


use remove_if.


contours.erase( std::remove_if(contours.begin(), contours.end(), [&](const Vector<Point>& vp){ return vp.empty(); }), contours.end());


struct is_empty { bool operator()(const Vector<Point>& vp) constt; { return vp.empty(); } } contours.erase( std::remove_if(contours.begin(), contours.end(), is_empty, contours.end());


  • Delaunay triangulation : too many triangles
  • Iterating through STL containers and removing/adding multiple items
  • How to remove elements from a vector based on a condition in another vector?
  • Python - Problems contour plotting offset grid of data
  • API's similar to GLUTesselator? [closed]
  • error: 'varName' was not declared in this scope [duplicate]
  • exceptions.TypeError: src is not a numpy array, neither a scalar
  • Entity Framework and Predicate Builder - Predicates being Ignored in SQL Query
  • how to create aggregation on a graph from CONSTRUCT
  • Case insensitive search in CQ5 using querybuilder
  • Qt - Cannot get lambda to work [duplicate]
  • Python equivalent of Scala's exists() function?
  • jQuery - resize an elements height to match window without refreshing, on window resize
  • Is there a package like bigmemory in R that can deal with large list objects?
  • Azure webjobs output logs indexing taking very long
  • Reduction and collapse clauses in OMP have some confusing points
  • xtable package: Skipping some rows in the output
  • ADO and msqli connections very slow
  • Marklogic : Query response time is very high
  • Jackson Parser: ignore deserializing for type mismatch
  • MongoDb aggregation
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Why is an OPTIONS request sent to the server?
  • Android screen density dpi vs ppi
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • How would I use PHP exceptions to define a redirect?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • How to extract text from Word files using C#?
  • When should I choose bucket sort over other sorting algorithms?
  • Unanticipated behavior
  • WPF Applying a trigger on binding failure
  • need help with bizarre java.net.HttpURLConnection behavior
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal