Improve the lambda used to return the compilation result in main.cpp

This commit is contained in:
Username404 2021-09-25 17:26:45 +02:00
parent 66e1926783
commit facf460923
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 6 additions and 3 deletions

View File

@ -44,9 +44,10 @@ int main(int argc, char* argv[]) {
const launch& Policy = not parallel ? launch::deferred : launch::async; const launch& Policy = not parallel ? launch::deferred : launch::async;
for (const string_view& fileName: uniqueFiles) { for (const string_view& fileName: uniqueFiles) {
if (fileName != "none") { if (fileName != "none") {
Units.push_back(async(Policy, [&fileName, &compile]() { pair<string, optional<Yerbacon::Exception>> returnedPair;
Units.push_back(async(Policy, [&returnedPair, &fileName, &compile]() {
try { try {
return pair(compile(fileName), optional<Yerbacon::Exception>()); returnedPair.first = compile(fileName);
} catch (const Yerbacon::Exception& e) { } catch (const Yerbacon::Exception& e) {
unsigned long lastSlash = 0; unsigned long lastSlash = 0;
unsigned long position1 = fileName.find_last_of('/'); unsigned long position1 = fileName.find_last_of('/');
@ -60,8 +61,10 @@ int main(int argc, char* argv[]) {
} }
#endif #endif
} }
return pair(string(fileName.substr(lastSlash + 1)), make_optional(e)); returnedPair.first = fileName.substr(lastSlash + 1);
returnedPair.second.emplace(e);
} }
return move(returnedPair);
})); }));
} }
} }