Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
Please
log in
to post a comment.
Extended Euclidean Algorithm
Expected GCD
std_minmax_unexpected_behaviour.cpp
GCC compiler bug (should output 0 1)
SVGAnimated Value
Jilebi Nimki
Faaaaak
Dar
variadic pointer to function template
Day3
stackse - search stackoverflow differently
Please log in to post a comment.