Fix the pairs returned by the futures of the Units set

This commit is contained in:
Username404 2021-09-26 12:38:33 +02:00
parent 700ab109d2
commit 43b4629a6d
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 6 additions and 6 deletions

View File

@ -42,10 +42,10 @@ int main(int argc, char* argv[]) {
vector<future<pair<string, optional<Yerbacon::Exception>>>> Units;
const launch& Policy = not parallel ? launch::deferred : launch::async;
for (const string_view& fileName: files) {
pair<string, optional<Yerbacon::Exception>> returnedPair;
Units.push_back(async(Policy, [&returnedPair, &fileName, &compile]() {
Units.push_back(async(Policy, [&fileName, &compile]() {
pair<string, optional<Yerbacon::Exception>> resultingPair;
try {
returnedPair.first = compile(fileName);
resultingPair.first = compile(fileName);
} catch (const Yerbacon::Exception& e) {
unsigned long lastSlash = 0;
unsigned long position1 = fileName.find_last_of('/');
@ -59,10 +59,10 @@ int main(int argc, char* argv[]) {
}
#endif
}
returnedPair.first = fileName.substr(lastSlash + 1);
returnedPair.second.emplace(e);
resultingPair.first = fileName.substr(lastSlash + 1);
resultingPair.second.emplace(e);
}
return move(returnedPair);
return resultingPair;
}));
}
if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n";