mirror of
https://github.com/Z3Prover/z3
synced 2025-04-10 19:27:06 +00:00
buffer: require a move constructor to avoid copies
remove unneded copy constructors from several classes
This commit is contained in:
parent
3d98bccc33
commit
98b5abb1d4
|
@ -130,7 +130,7 @@ public:
|
|||
explicit parameter(unsigned ext_id, bool):m_kind(PARAM_EXTERNAL), m_ext_id(ext_id) {}
|
||||
parameter(parameter const&);
|
||||
|
||||
parameter(parameter && other) : m_kind(other.m_kind) {
|
||||
parameter(parameter && other) noexcept : m_kind(other.m_kind) {
|
||||
switch (other.m_kind) {
|
||||
case PARAM_INT: m_int = other.get_int(); break;
|
||||
case PARAM_AST: m_ast = other.get_ast(); break;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "util/rlimit.h"
|
||||
#include "util/statistics.h"
|
||||
#include "math/dd/dd_pdd.h"
|
||||
#include <cstring>
|
||||
|
||||
namespace dd {
|
||||
|
||||
|
|
|
@ -25,14 +25,14 @@ Revision History:
|
|||
|
||||
--*/
|
||||
|
||||
#ifndef HILBERT_BASIS_H_
|
||||
#define HILBERT_BASIS_H_
|
||||
#pragma once
|
||||
|
||||
#include "util/rational.h"
|
||||
#include "util/lbool.h"
|
||||
#include "util/statistics.h"
|
||||
#include "util/checked_int64.h"
|
||||
#include "util/rlimit.h"
|
||||
#include <cstring>
|
||||
|
||||
typedef vector<rational> rational_vector;
|
||||
|
||||
|
@ -198,6 +198,3 @@ public:
|
|||
void reset_statistics();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,7 @@ Revision History:
|
|||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include "math/lp/lp_utils.h"
|
||||
#include "util/stopwatch.h"
|
||||
#include "math/lp/lp_types.h"
|
||||
|
|
|
@ -16,11 +16,11 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
#ifndef SPARSE_MATRIX_H_
|
||||
#define SPARSE_MATRIX_H_
|
||||
#pragma once
|
||||
|
||||
#include "util/mpq_inf.h"
|
||||
#include "util/statistics.h"
|
||||
#include <cstring>
|
||||
|
||||
namespace simplex {
|
||||
|
||||
|
@ -271,6 +271,3 @@ namespace simplex {
|
|||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,8 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef SUBPAVING_TYPES_H_
|
||||
#define SUBPAVING_TYPES_H_
|
||||
#pragma once
|
||||
|
||||
namespace subpaving {
|
||||
|
||||
|
@ -34,7 +33,6 @@ class power : public std::pair<var, unsigned> {
|
|||
public:
|
||||
power():std::pair<var, unsigned>() {}
|
||||
power(var v, unsigned d):std::pair<var, unsigned>(v, d) {}
|
||||
power(power const & p):std::pair<var, unsigned>(p) {}
|
||||
var x() const { return first; }
|
||||
var get_var() const { return first; }
|
||||
unsigned degree() const { return second; }
|
||||
|
@ -47,6 +45,4 @@ struct display_var_proc {
|
|||
virtual void operator()(std::ostream & out, var x) const { out << "x" << x; }
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -228,6 +228,7 @@ interval::interval(v_dependency_manager & m, rational const & val, bool open, bo
|
|||
}
|
||||
|
||||
interval & interval::operator=(interval const & other) {
|
||||
SASSERT(&m == &other.m);
|
||||
m_lower = other.m_lower;
|
||||
m_upper = other.m_upper;
|
||||
m_lower_open = other.m_lower_open;
|
||||
|
@ -237,6 +238,17 @@ interval & interval::operator=(interval const & other) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
interval & interval::operator=(interval && other) {
|
||||
SASSERT(&m == &other.m);
|
||||
m_lower = std::move(other.m_lower);
|
||||
m_upper = std::move(other.m_upper);
|
||||
m_lower_open = other.m_lower_open;
|
||||
m_upper_open = other.m_upper_open;
|
||||
m_lower_dep = other.m_lower_dep;
|
||||
m_upper_dep = other.m_upper_dep;
|
||||
return *this;
|
||||
}
|
||||
|
||||
interval & interval::operator+=(interval const & other) {
|
||||
m_lower += other.m_lower;
|
||||
m_upper += other.m_upper;
|
||||
|
|
|
@ -16,8 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef OLD_INTERVAL_H_
|
||||
#define OLD_INTERVAL_H_
|
||||
#pragma once
|
||||
|
||||
#include "util/rational.h"
|
||||
#include "util/dependency.h"
|
||||
|
@ -81,6 +80,8 @@ public:
|
|||
explicit old_interval(v_dependency_manager & m, rational const & val, v_dependency * l_dep = nullptr, v_dependency * u_dep = nullptr);
|
||||
explicit old_interval(v_dependency_manager & m, rational const & val, bool open, bool lower, v_dependency * d);
|
||||
explicit old_interval(v_dependency_manager & m, ext_numeral const& lower, bool l_open, v_dependency * l_dep, ext_numeral const & upper, bool u_open, v_dependency * u_dep);
|
||||
old_interval(const old_interval&) = default;
|
||||
old_interval(old_interval&&) = default;
|
||||
|
||||
bool minus_infinity() const { return m_lower.is_infinite(); }
|
||||
bool plus_infinity() const { return m_upper.is_infinite(); }
|
||||
|
@ -91,6 +92,7 @@ public:
|
|||
rational const & get_lower_value() const { SASSERT(!minus_infinity()); return m_lower.to_rational(); }
|
||||
rational const & get_upper_value() const { SASSERT(!plus_infinity()); return m_upper.to_rational(); }
|
||||
old_interval & operator=(old_interval const & other);
|
||||
old_interval & operator=(old_interval && other);
|
||||
old_interval & operator+=(old_interval const & other);
|
||||
old_interval & operator-=(old_interval const & other);
|
||||
old_interval & operator*=(old_interval const & other);
|
||||
|
@ -125,12 +127,5 @@ inline old_interval operator/(old_interval const & i1, old_interval const & i2)
|
|||
inline old_interval expt(old_interval const & i, unsigned n) { old_interval tmp(i); tmp.expt(n); return tmp; }
|
||||
inline std::ostream & operator<<(std::ostream & out, old_interval const & i) { i.display(out); return out; }
|
||||
|
||||
struct interval_detail{};
|
||||
inline std::pair<old_interval, interval_detail> wd(old_interval const & i) { interval_detail d; return std::make_pair(i, d); }
|
||||
inline std::ostream & operator<<(std::ostream & out, std::pair<old_interval, interval_detail> const & p) { p.first.display_with_dependencies(out); return out; }
|
||||
|
||||
// allow "customers" of this file to keep using interval
|
||||
#define interval old_interval
|
||||
|
||||
#endif /* OLD_INTERVAL_H_ */
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#include<string.h>
|
||||
#include <type_traits>
|
||||
#include "util/memory_manager.h"
|
||||
|
||||
template<typename T, bool CallDestructors=true, unsigned INITIAL_SIZE=16>
|
||||
|
@ -39,6 +39,7 @@ protected:
|
|||
}
|
||||
|
||||
void expand() {
|
||||
static_assert(std::is_nothrow_move_constructible<T>::value);
|
||||
unsigned new_capacity = m_capacity << 1;
|
||||
T * new_buffer = reinterpret_cast<T*>(memory::allocate(sizeof(T) * new_capacity));
|
||||
for (unsigned i = 0; i < m_pos; ++i) {
|
||||
|
|
|
@ -21,8 +21,7 @@ Revision History:
|
|||
|
||||
--*/
|
||||
|
||||
#ifndef CHECKED_INT64_H_
|
||||
#define CHECKED_INT64_H_
|
||||
#pragma once
|
||||
|
||||
#include "util/z3_exception.h"
|
||||
#include "util/rational.h"
|
||||
|
@ -38,7 +37,6 @@ public:
|
|||
|
||||
checked_int64(): m_value(0) {}
|
||||
checked_int64(int64_t v): m_value(v) {}
|
||||
checked_int64(checked_int64 const& other) { m_value = other.m_value; }
|
||||
|
||||
class overflow_exception : public z3_exception {
|
||||
char const * msg() const override { return "checked_int64 overflow/underflow";}
|
||||
|
@ -217,5 +215,3 @@ inline checked_int64<CHECK> operator*(checked_int64<CHECK> const& a, checked_int
|
|||
result *= b;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,10 +16,10 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef HWF_H_
|
||||
#define HWF_H_
|
||||
#pragma once
|
||||
|
||||
#include<string>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include "util/mpz.h"
|
||||
#include "util/mpq.h"
|
||||
#include "util/mpf.h"
|
||||
|
@ -172,5 +172,3 @@ protected:
|
|||
|
||||
typedef _scoped_numeral<hwf_manager> scoped_hwf;
|
||||
typedef _scoped_numeral_vector<hwf_manager> scoped_hwf_vector;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,6 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include <cstring>
|
||||
#include<sstream>
|
||||
#include<iomanip>
|
||||
#include "util/mpf.h"
|
||||
|
|
|
@ -16,6 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include <cstring>
|
||||
#include<sstream>
|
||||
#include<iomanip>
|
||||
#include "util/mpfx.h"
|
||||
|
|
|
@ -16,6 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include "util/mpz.h"
|
||||
|
|
|
@ -16,8 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef MPZ_H_
|
||||
#define MPZ_H_
|
||||
#pragma once
|
||||
|
||||
#include<string>
|
||||
#include "util/mutex.h"
|
||||
|
@ -104,7 +103,7 @@ public:
|
|||
mpz(int v):m_val(v), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {}
|
||||
mpz():m_val(0), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {}
|
||||
mpz(mpz_type* ptr): m_val(0), m_kind(mpz_small), m_owner(mpz_ext), m_ptr(ptr) { SASSERT(ptr);}
|
||||
mpz(mpz && other) : m_val(other.m_val), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {
|
||||
mpz(mpz && other) noexcept : m_val(other.m_val), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {
|
||||
std::swap(m_ptr, other.m_ptr);
|
||||
unsigned o = m_owner; m_owner = other.m_owner; other.m_owner = o;
|
||||
unsigned k = m_kind; m_kind = other.m_kind; other.m_kind = k;
|
||||
|
@ -734,6 +733,3 @@ typedef mpz_manager<false> unsynch_mpz_manager;
|
|||
typedef _scoped_numeral<unsynch_mpz_manager> scoped_mpz;
|
||||
typedef _scoped_numeral<synch_mpz_manager> scoped_synch_mpz;
|
||||
typedef _scoped_numeral_vector<unsynch_mpz_manager> scoped_mpz_vector;
|
||||
|
||||
#endif /* MPZ_H_ */
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef RATIONAL_H_
|
||||
#define RATIONAL_H_
|
||||
#pragma once
|
||||
|
||||
#include "util/mpq.h"
|
||||
|
||||
|
@ -41,7 +40,7 @@ public:
|
|||
rational() {}
|
||||
|
||||
rational(rational const & r) { m().set(m_val, r.m_val); }
|
||||
rational(rational && r) : m_val(std::move(r.m_val)) {}
|
||||
rational(rational && r) noexcept : m_val(std::move(r.m_val)) {}
|
||||
|
||||
explicit rational(int n) { m().set(m_val, n); }
|
||||
|
||||
|
@ -576,7 +575,3 @@ inline rational gcd(rational const & r1, rational const & r2, rational & a, rati
|
|||
rational::m().gcd(r1.m_val, r2.m_val, a.m_val, b.m_val, result.m_val);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif /* RATIONAL_H_ */
|
||||
|
||||
|
|
Loading…
Reference in a new issue