Search
 
SCRIPT & CODE EXAMPLE
 

CPP

remove element from vector on condition c++

v.erase(std::remove_if(
    v.begin(), v.end(),
    [](const int& x) { 
        return x > 10; // put your condition here
    }), v.end());
// therefore elements > 10 are removed, leaving only elements<= 10
Comment

PREVIOUS NEXT
Code Example
Cpp :: locate specific string letters c++ 
Cpp :: how to read a line from the console in c++ 
Cpp :: convert string to char c++ 
Cpp :: helloworld in c++ 
Cpp :: how to play sound in c++ 
Cpp :: binary string addition 
Cpp :: insertion sort c++ 
Cpp :: check if point is left or right of vector 
Cpp :: lopping over an array c++ 
Cpp :: integer type validation c++ 
Cpp :: c++ string remove first character 
Cpp :: how to make for loop in c++ 
Cpp :: reverse c++ string 
Cpp :: opencv rgb to gray c++ 
Cpp :: conditional operator in cpp 
Cpp :: how to string to integer in c++ 
Cpp :: c++ case 
Cpp :: sort stl 
Cpp :: string length c++ 
Cpp :: slice std::array cpp 
Cpp :: c++ console color 
Cpp :: vector.find() 
Cpp :: segmented sieve cpp 
Cpp :: Story of c++ 
Cpp :: increment c++ 
Cpp :: hamming distance c++ 
Cpp :: c++ get string between two characters 
Cpp :: cstring to string 
Cpp :: initialize vector of vector c++ 
Cpp :: stack implementation using class in c++ 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =