Add a "unit" alias to main.cpp

This commit is contained in:
Username404 2021-12-20 20:31:54 +01:00
parent afe411bb86
commit a0e185adb5
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 4 additions and 3 deletions

View File

@ -57,7 +57,8 @@ int main(int argc, char* argv[]) {
}; };
int8_t exit_code = EXIT_SUCCESS; int8_t exit_code = EXIT_SUCCESS;
if (!files.empty()) { if (!files.empty()) {
vector<future<pair<string, optional<Yerbacon::Exception>>>> Units(files.size()); using unit = future<pair<string, optional<Yerbacon::Exception>>>;
vector<unit> Units(files.size());
const launch& Policy = not parallel ? launch::deferred : launch::async; const launch& Policy = not parallel ? launch::deferred : launch::async;
transform(files.cbegin(), files.cend(), Units.begin(), [&Policy, &compile](const string_view& fileName){ transform(files.cbegin(), files.cend(), Units.begin(), [&Policy, &compile](const string_view& fileName){
return async(Policy, [&fileName, &compile]() { return async(Policy, [&fileName, &compile]() {
@ -81,8 +82,8 @@ int main(int argc, char* argv[]) {
}); });
}); });
if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n"; if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n";
if (any_of(Units.rbegin(), Units.rend(), [&printResult](future<pair<string, optional<Yerbacon::Exception>>>& currentFuture) -> bool { if (any_of(Units.rbegin(), Units.rend(), [&printResult](unit& currentFuture) -> bool {
const auto&& result = currentFuture.get(); const pair result = currentFuture.get();
const bool is_exception = result.second.has_value(); const bool is_exception = result.second.has_value();
if (not is_exception) { if (not is_exception) {
if (printResult && !(result.first.empty() || all_of(result.first.begin(), result.first.end(), [](const char& character){ if (printResult && !(result.first.empty() || all_of(result.first.begin(), result.first.end(), [](const char& character){