From facf4609237f47c7f90e4d6e380b6451a253b833 Mon Sep 17 00:00:00 2001 From: Username404 Date: Sat, 25 Sep 2021 17:26:45 +0200 Subject: [PATCH] Improve the lambda used to return the compilation result in main.cpp --- src/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1e77e27..4f32749 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,9 +44,10 @@ int main(int argc, char* argv[]) { const launch& Policy = not parallel ? launch::deferred : launch::async; for (const string_view& fileName: uniqueFiles) { if (fileName != "none") { - Units.push_back(async(Policy, [&fileName, &compile]() { + pair> returnedPair; + Units.push_back(async(Policy, [&returnedPair, &fileName, &compile]() { try { - return pair(compile(fileName), optional()); + returnedPair.first = compile(fileName); } catch (const Yerbacon::Exception& e) { unsigned long lastSlash = 0; unsigned long position1 = fileName.find_last_of('/'); @@ -60,8 +61,10 @@ int main(int argc, char* argv[]) { } #endif } - return pair(string(fileName.substr(lastSlash + 1)), make_optional(e)); + returnedPair.first = fileName.substr(lastSlash + 1); + returnedPair.second.emplace(e); } + return move(returnedPair); })); } }