3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

Move on_scope_exit to util.h

This commit is contained in:
Jakob Rath 2022-10-07 14:23:26 +02:00
parent dcd6c01a90
commit e18bc46de1
2 changed files with 15 additions and 15 deletions

View file

@ -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()
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();
}
};