mirror of
https://github.com/Z3Prover/z3
synced 2025-07-23 04:38:53 +00:00
Move on_scope_exit to util.h
This commit is contained in:
parent
dcd6c01a90
commit
e18bc46de1
2 changed files with 15 additions and 15 deletions
|
@ -573,25 +573,12 @@ namespace polysat {
|
||||||
pdecide(m_free_pvars.next_var());
|
pdecide(m_free_pvars.next_var());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Basic version of https://en.cppreference.com/w/cpp/experimental/scope_exit
|
|
||||||
template <typename Callable>
|
|
||||||
class on_scope_exit final {
|
|
||||||
Callable m_ef;
|
|
||||||
public:
|
|
||||||
explicit on_scope_exit(Callable&& ef)
|
|
||||||
: m_ef(std::forward<Callable>(ef))
|
|
||||||
{ }
|
|
||||||
~on_scope_exit() {
|
|
||||||
m_ef();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void solver::bdecide() {
|
void solver::bdecide() {
|
||||||
clause& lemma = *m_lemmas[m_lemmas_qhead++];
|
clause& lemma = *m_lemmas[m_lemmas_qhead++];
|
||||||
on_scope_exit update_trail([this]() {
|
on_scope_exit update_trail = [this]() {
|
||||||
// must be done after push_level, but also if we return early.
|
// must be done after push_level, but also if we return early.
|
||||||
m_trail.push_back(trail_instr_t::lemma_qhead_i);
|
m_trail.push_back(trail_instr_t::lemma_qhead_i);
|
||||||
});
|
};
|
||||||
|
|
||||||
LOG_H2("Decide on non-asserting lemma: " << lemma);
|
LOG_H2("Decide on non-asserting lemma: " << lemma);
|
||||||
sat::literal choice = sat::null_literal;
|
sat::literal choice = sat::null_literal;
|
||||||
|
|
|
@ -400,3 +400,16 @@ std::size_t count_if(Container const& c, Predicate p)
|
||||||
using std::begin, std::end; // allows begin(c) to also find c.begin()
|
using std::begin, std::end; // allows begin(c) to also find c.begin()
|
||||||
return std::count_if(begin(c), end(c), std::forward<Predicate>(p));
|
return std::count_if(begin(c), end(c), std::forward<Predicate>(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Basic version of https://en.cppreference.com/w/cpp/experimental/scope_exit
|
||||||
|
template <typename Callable>
|
||||||
|
class on_scope_exit final {
|
||||||
|
Callable m_ef;
|
||||||
|
public:
|
||||||
|
on_scope_exit(Callable&& ef)
|
||||||
|
: m_ef(std::forward<Callable>(ef))
|
||||||
|
{ }
|
||||||
|
~on_scope_exit() {
|
||||||
|
m_ef();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue