Daily bit(e) of C++ | std::copy_if, std::remove_copy_if
Daily bit(e) of C++ ♻️71, Selectively copying elements using std::copy_if and std::remove_copy_if.
If you need to selectively copy elements from one range to another, the standard offers the std::copy_if and std::remove_copy_if algorithms. The algorithms will copy elements for which the predicate returns true (std::copy_if) or false (std::remove_copy_if).
Both algorithms support a C++17 parallel and C++20 range variant.