AlexSSH

Untitled

Feb 14th, 2023
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <execution>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     std::vector<int> from_vector(10);
  8.     std::iota(from_vector.begin(), from_vector.end(), 0);
  9.     std::vector<int> to_vector(10);
  10.     auto tmp = std::copy_if(execution::parallel_policy, from_vector.begin(), from_vector.end(),
  11.                             std::back_inserter(to_vector),
  12.                             [](int x) { return x % 2 == 0; });
  13.     to_vector.resize(std::distance(to_vector.begin(), tmp));
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment