Fix XOR condition (#5567)

This commit is contained in:
Jesse Hills 2023-10-19 15:36:01 +13:00
parent 61b8004536
commit 8c2d9101d5
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

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: