diff --git a/src/main.cpp b/src/main.cpp index 4a7acc9..b892019 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,7 +42,7 @@ int main(int argc, char* argv[]) { if (!files.empty()) { vector>>> Units; const launch& Policy = not parallel ? launch::deferred : launch::async; - for (const string_view& fileName: files) { + for_each(files.begin(), files.end(), [&Units, &Policy, &compile](const string_view& fileName){ Units.push_back(async(Policy, [&fileName, &compile]() { pair> resultingPair; try { @@ -65,9 +65,9 @@ int main(int argc, char* argv[]) { } return resultingPair; })); - } + }); if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n"; - for (future>>& currentFuture: Units) { + for_each(Units.begin(), Units.end(), [&printResult](future>>& currentFuture) { const auto&& result = currentFuture.get(); if (not result.second.has_value()) { if (printResult) cout << result.first; @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) { cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what(); } cout << "\n\n"; - } + }); } else cout << "No valid file provided.\n"; return EXIT_SUCCESS; } \ No newline at end of file