Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
remove_if_30-Seconds-of-C++
#include <iostream> #include <vector> #include <algorithm> int main() { auto isOdd = [](int i) { return ((i%2) == 1); }; std::vector<int> v {1, 2, 3, 4, 5}; // Remove all elements that returns true for isOdd auto newEndIt = std::remove_if(v.begin(), v.end(), isOdd); // Erase elements from [newEndIt, v.end()] v.erase(newEndIt, v.end()); // v is now {2, 4} for (auto value : v) { std::cout << value << " "; } }
run
|
edit
|
history
|
help
0
printAllPathsInMatrix
Test 5(2020)
References Pt 1 C++
Mr
hacker
TraiectorieIdeala2
replace_if-30-Seconds-of-C++
Intersected Rectangles
always_late
point to a rvalue