一:功能
将容器中满足给定条件的元素拷贝到另一个容器中
二:用法
cpp
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
int main() {
std::vector<int> data{ 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> even;
auto is_even = [](int v) { return v % 2 == 0; };
std::ranges::copy_if(data, std::back_inserter(even), is_even);
std::cout << "even == {";
std::string delim;
for (auto v : even)
std::cout << std::exchange(delim, ", ") << v;
std::cout << "}\n";
}