Last active
January 1, 2025 07:41
-
-
Save arnabanimesh/5a4785ef6d571294d6c649117d7a7dfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <numeric> | |
#include <string> | |
#include <ranges> | |
#include <execution> | |
#include <iterator> | |
#include <vector> | |
struct Output | |
{ | |
int32_t serial; | |
std::string name; | |
int32_t count; | |
}; | |
int main() | |
{ | |
std::vector<int32_t> vec_iter = {0, 1}; | |
std::vector<Output> output_list(vec_iter.size()); | |
// mutex guard is not required as each element in vec_iter will be unique, | |
// and the output_list is not std::vector<bool> | |
std::for_each(std::execution::par, vec_iter.begin(), vec_iter.end(), [&](int32_t elem) | |
{ output_list[elem] = {1, "A", 1000}; }); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment