uibk_703807-Advanced-CXX/topic/little_features/execution_policy.cpp

16 lines
368 B
C++
Raw Permalink Normal View History

2021-01-21 15:08:19 +01:00
#include <algorithm>
#include <array>
#include <execution>
#include <iostream>
int main()
{
std::vector<int> numbers;
for (auto i = 0; i < 1000; i++) {
numbers.push_back(i);
}
// Output should be malformed since there is no synchronization in place.
std::for_each(std::execution::par, numbers.begin(), numbers.end(), [](int i) { std::cout << i << "\n"; });
}