Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename Container, typename Predicate>
- vector<typename Container::value_type> CopyIfUnordered(const Container& container, Predicate predicate) {
- vector<typename Container::value_type> result(container.size());
- atomic<int> size = 0;
- for_each(
- execution::par,
- container.begin(), container.end(),
- [&](const auto& value) {
- if (predicate(value)) {
- typename Container::value_type* destination;
- {
- destination = &result[size++];
- }
- *destination = value;
- }
- }
- );
- result.resize(size);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement