From 239ace43536e5dc982aacb2a8c22e29bf5aaf15a Mon Sep 17 00:00:00 2001 From: Zachary Wimer Date: Thu, 15 Apr 2021 13:37:31 -0700 Subject: [PATCH] expr move semantics supported via ast (#5190) --- src/api/c++/z3++.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 625964347..c99979355 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -497,6 +497,7 @@ namespace z3 { ast(context & c):object(c), m_ast(0) {} ast(context & c, Z3_ast n):object(c), m_ast(n) { Z3_inc_ref(ctx(), m_ast); } ast(ast const & s):object(s), m_ast(s.m_ast) { Z3_inc_ref(ctx(), m_ast); } + ast(ast && s) noexcept : object(std::forward(s)), m_ast(s.m_ast) { s.m_ast = nullptr; } ~ast() { if (m_ast) Z3_dec_ref(*m_ctx, m_ast); } operator Z3_ast() const { return m_ast; } operator bool() const { return m_ast != 0; } @@ -508,6 +509,12 @@ namespace z3 { m_ast = s.m_ast; return *this; } + ast & operator=(ast && s) noexcept { + object::operator=(std::forward(s)); + m_ast = s.m_ast; + s.m_ast = nullptr; + return *this; + } Z3_ast_kind kind() const { Z3_ast_kind r = Z3_get_ast_kind(ctx(), m_ast); check_error(); return r; } unsigned hash() const { unsigned r = Z3_get_ast_hash(ctx(), m_ast); check_error(); return r; } friend std::ostream & operator<<(std::ostream & out, ast const & n);