15 explicit Predicate(
const std::function<
bool(
void)>& predicate_function) : predicate_(std::move(predicate_function)) {}
17 bool get_value()
const {
return predicate_(); }
19 void set_predicate(
const std::function<
bool(
void)>& predicate_function) { predicate_ = predicate_function; }
21 std::optional<bool> query() {
22 if (
const auto new_value = predicate_(); !previous_value_ || new_value != *previous_value_) {
23 previous_value_ = new_value;
30 std::function<bool(
void)> predicate_;
31 std::optional<bool> previous_value_;