Fix XOR condition (#5567)

This commit is contained in:
Jesse Hills 2023-10-19 15:36:01 +13:00 committed by GitHub
parent e99b8aaf96
commit b9d72231b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,12 +52,12 @@ template<typename... Ts> class XorCondition : public Condition<Ts...> {
public:
explicit XorCondition(const std::vector<Condition<Ts...> *> &conditions) : conditions_(conditions) {}
bool check(Ts... x) override {
bool xor_state = false;
size_t result = 0;
for (auto *condition : this->conditions_) {
xor_state = xor_state ^ condition->check(x...);
result += condition->check(x...);
}
return xor_state;
return result == 1;
}
protected: