Skip to content

Commit

Permalink
use std::all_of
Browse files Browse the repository at this point in the history
  • Loading branch information
ludviggunne committed Oct 3, 2024
1 parent 43be75e commit e15fd39
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3714,12 +3714,10 @@ bool isExhaustiveSwitch(const Token *startbrace)
return switchValues.count(0) && switchValues.count(1);

if (condition->valueType()->isEnum()) {
const Scope *typeScope = condition->valueType()->typeScope;
const std::vector<Enumerator> &enumList = typeScope->enumeratorList;
const std::size_t usedValues = std::count_if(enumList.cbegin(), enumList.cend(), [&](const Enumerator &e) {
return e.value_known && switchValues.count(e.value);
const std::vector<Enumerator> &enumList = condition->valueType()->typeScope->enumeratorList;
return std::all_of(enumList.cbegin(), enumList.cend(), [&](const Enumerator &e) {
return !e.value_known || switchValues.count(e.value);
});
return enumList.size() == usedValues;
}

return false;
Expand Down

0 comments on commit e15fd39

Please sign in to comment.