3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-23 19:47:52 +00:00

use iterators on goal and other refactoring

This commit is contained in:
Nikolaj Bjorner 2025-03-16 20:04:04 -07:00
parent eb97fcc273
commit 2e2a2e28df
8 changed files with 77 additions and 53 deletions

View file

@ -165,6 +165,41 @@ public:
bool is_cnf() const;
goal * translate(ast_translation & translator) const;
class iterator {
public:
using value_type = std::tuple<expr*, expr_dependency*, proof*>;
using reference = value_type&;
using pointer = value_type*;
using difference_type = std::ptrdiff_t;
using iterator_category = std::forward_iterator_tag;
iterator(goal const* g, unsigned idx) : m_goal(g), m_idx(idx) {}
value_type operator*() const {
return std::make_tuple(m_goal->form(m_idx), m_goal->dep(m_idx), m_goal->pr(m_idx));
}
iterator& operator++() {
++m_idx;
return *this;
}
bool operator==(const iterator& other) const {
return m_goal == other.m_goal && m_idx == other.m_idx;
}
bool operator!=(const iterator& other) const {
return !(*this == other);
}
private:
goal const* m_goal;
unsigned m_idx;
};
iterator begin() const { return iterator(this, 0); }
iterator end() const { return iterator(this, size()); }
};
std::ostream & operator<<(std::ostream & out, goal::precision p);