3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-09 10:35:36 +00:00

Merge pull request #8508 from Z3Prover/copilot/add-move-constructor-z3-context

Add move semantics to z3::context
This commit is contained in:
Nikolaj Bjorner 2026-02-05 23:03:21 -08:00 committed by GitHub
commit 7d6c809f28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -214,6 +214,24 @@ namespace z3 {
public:
context() { config c; init(c); }
context(config & c) { init(c); }
context(context && other) noexcept
: m_enable_exceptions(other.m_enable_exceptions),
m_rounding_mode(other.m_rounding_mode),
m_ctx(other.m_ctx) {
other.m_ctx = nullptr;
}
context & operator=(context && other) noexcept {
if (this != &other) {
if (m_ctx) Z3_del_context(m_ctx);
m_enable_exceptions = other.m_enable_exceptions;
m_rounding_mode = other.m_rounding_mode;
m_ctx = other.m_ctx;
other.m_ctx = nullptr;
}
return *this;
}
~context() { if (m_ctx) Z3_del_context(m_ctx); }
operator Z3_context() const { return m_ctx; }