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

Use noexcept more. (#7058)

This commit is contained in:
Bruce Mitchener 2023-12-16 19:14:53 +07:00 committed by GitHub
parent b44ab2f620
commit 50e0fd3ba6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 97 additions and 112 deletions

View file

@ -184,7 +184,7 @@ public:
T const * data() const { return m_data; }
T * data() { return m_data; }
void swap(array & other) {
void swap(array & other) noexcept {
std::swap(m_data, other.m_data);
}

View file

@ -52,8 +52,8 @@ public:
interval const & get() const { return m_interval; }
interval & get() { return m_interval; }
void reset() { m().reset(m_interval); }
void swap(scoped_interval & a) { m().swap(m_interval, a.m_interval); }
void swap(interval & a) { m().swap(m_interval, a); }
void swap(scoped_interval & a) noexcept { m().swap(m_interval, a.m_interval); }
void swap(interval & a) noexcept { m().swap(m_interval, a); }
bound const & lower() const { return m_interval.lower(); }
bound const & upper() const { return m_interval.upper(); }
bound & lower() { return m_interval.lower(); }
@ -146,7 +146,7 @@ public:
m().set(a.m_upper, n);
}
void swap(interval & a, interval & b) {
void swap(interval & a, interval & b) noexcept {
m().swap(a.m_lower, b.m_lower);
m().swap(a.m_upper, b.m_upper);
}

View file

@ -98,7 +98,7 @@ public:
m_num_bits = 0;
}
void swap(bit_vector & other) {
void swap(bit_vector & other) noexcept {
std::swap(m_data, other.m_data);
std::swap(m_num_bits, other.m_num_bits);
std::swap(m_capacity, other.m_capacity);

View file

@ -553,7 +553,7 @@ public:
iterator begin() const { return iterator(m_table, m_table + m_slots); }
iterator end() const { return iterator(); }
void swap(chashtable & other) {
void swap(chashtable & other) noexcept {
std::swap(m_table, other.m_table);
std::swap(m_capacity, other.m_capacity);
std::swap(m_init_slots, other.m_init_slots);

View file

@ -76,7 +76,7 @@ public:
static void set(double & a, unsigned val) { a = static_cast<double>(val); }
static void set(double & a, int64_t val) { a = static_cast<double>(val); }
static void set(double & a, uint64_t val) { a = static_cast<double>(val); }
static void swap(double & a, double & b) { std::swap(a, b); }
static void swap(double & a, double & b) noexcept { std::swap(a, b); }
bool is_pos(double a) const { return a > m_zero_tolerance; }
bool is_neg(double a) const { return a < m_zero_tolerance; }
bool is_zero(double a) const { return -m_zero_tolerance <= a && a <= m_zero_tolerance; }

View file

@ -45,7 +45,7 @@ public:
m_manager.set(m_one, ebits, sbits, 1);
}
f2n(f2n && other) : m_manager(other.m_manager), m_mode(other.m_mode), m_ebits(other.m_ebits), m_sbits(other.m_sbits),
f2n(f2n && other) noexcept : m_manager(other.m_manager), m_mode(other.m_mode), m_ebits(other.m_ebits), m_sbits(other.m_sbits),
m_tmp1(std::move(other.m_tmp1)), m_one(std::move(other.m_one)) {}
~f2n() {
@ -86,7 +86,7 @@ public:
void set(numeral & o, numeral const & x) { m().set(o, x); check(o); }
void set(numeral & o, mpq const & x) { m().set(o, m_ebits, m_sbits, m_mode, x); check(o); }
void reset(numeral & o) { m().reset(o, m_ebits, m_sbits); }
static void swap(numeral & x, numeral & y) { x.swap(y); }
static void swap(numeral & x, numeral & y) noexcept { x.swap(y); }
void add(numeral const & x, numeral const & y, numeral & o) { m().add(m_mode, x, y, o); check(o); }
void sub(numeral const & x, numeral const & y, numeral & o) { m().sub(m_mode, x, y, o); check(o); }

View file

@ -283,7 +283,7 @@ public:
delete_table();
}
void swap(core_hashtable & source) {
void swap(core_hashtable & source) noexcept {
std::swap(m_table, source.m_table);
std::swap(m_capacity, source.m_capacity);
std::swap(m_size, source.m_size);

View file

@ -259,7 +259,7 @@ public:
return m_values.end();
}
void swap(heap & other) {
void swap(heap & other) noexcept {
if (this != &other) {
CASSERT("heap", other.check_invariant());
CASSERT("heap", check_invariant());

View file

@ -35,7 +35,7 @@ class hwf {
}
public:
void swap(hwf & other) { std::swap(value, other.value); }
void swap(hwf & other) noexcept { std::swap(value, other.value); }
};

View file

@ -38,7 +38,7 @@ class inf_eps_rational {
struct eq_proc { bool operator()(inf_eps_rational const& r1, inf_eps_rational const& r2) const { return r1 == r2; } };
void swap(inf_eps_rational & n) {
void swap(inf_eps_rational & n) noexcept {
m_infty.swap(n.m_infty);
m_r.swap(n.m_r);
}

View file

@ -43,7 +43,7 @@ class inf_int_rational {
struct eq_proc { bool operator()(inf_int_rational const& r1, inf_int_rational const& r2) const { return r1 == r2; } };
void swap(inf_int_rational & n) {
void swap(inf_int_rational & n) noexcept {
m_first.swap(n.m_first);
std::swap(m_second, n.m_second);
}

View file

@ -44,7 +44,7 @@ class inf_rational {
struct eq_proc { bool operator()(inf_rational const& r1, inf_rational const& r2) const { return r1 == r2; } };
void swap(inf_rational & n) {
void swap(inf_rational & n) noexcept {
m_first.swap(n.m_first);
m_second.swap(n.m_second);
}

View file

@ -37,7 +37,7 @@ class inf_s_integer {
struct eq_proc { bool operator()(inf_s_integer const& r1, inf_s_integer const& r2) const { return r1 == r2; } };
void swap(inf_s_integer & n) {
void swap(inf_s_integer & n) noexcept {
std::swap(m_first, n.m_first);
std::swap(m_second, n.m_second);
}

View file

@ -184,7 +184,7 @@ public:
unsigned long long get_num_collision() const { return m_table.get_num_collision(); }
void swap(table2map & other) {
void swap(table2map & other) noexcept {
m_table.swap(other.m_table);
}

View file

@ -40,10 +40,10 @@ public:
mpbq(int v, unsigned k):m_num(v), m_k(k) {}
mpz const & numerator() const { return m_num; }
unsigned k() const { return m_k; }
void swap(mpbq & other) { m_num.swap(other.m_num); std::swap(m_k, other.m_k); }
void swap(mpbq & other) noexcept { m_num.swap(other.m_num); std::swap(m_k, other.m_k); }
};
inline void swap(mpbq & m1, mpbq & m2) { m1.swap(m2); }
inline void swap(mpbq & m1, mpbq & m2) noexcept { m1.swap(m2); }
typedef svector<mpbq> mpbq_vector;
@ -72,7 +72,7 @@ public:
mpbq_manager(unsynch_mpz_manager & m);
~mpbq_manager();
static void swap(mpbq & a, mpbq & b) { a.swap(b); }
static void swap(mpbq & a, mpbq & b) noexcept { a.swap(b); }
void del(mpbq & a) { m_manager.del(a.m_num); }
void reset(mpbq & a) { m_manager.reset(a.m_num); a.m_k = 0; }

View file

@ -41,7 +41,7 @@ mpf::mpf(unsigned _ebits, unsigned _sbits):
set(ebits, sbits);
}
void mpf::swap(mpf & other) {
void mpf::swap(mpf & other) noexcept {
unsigned tmp = ebits;
ebits = other.ebits;
other.ebits = tmp;

View file

@ -52,7 +52,7 @@ public:
mpf & operator=(mpf const & other) = delete;
unsigned get_ebits() const { return ebits; }
unsigned get_sbits() const { return sbits; }
void swap(mpf & other);
void swap(mpf & other) noexcept;
};
class mpf_manager {
@ -87,7 +87,7 @@ public:
void neg(mpf & o);
void neg(mpf const & x, mpf & o);
void swap(mpf& a, mpf& b) { a.swap(b); }
void swap(mpf& a, mpf& b) noexcept { a.swap(b); }
bool is_zero(mpf const & x);
bool is_neg(mpf const & x);

View file

@ -44,14 +44,14 @@ public:
m_exponent(0) {
}
void swap(mpff & other) {
void swap(mpff & other) noexcept {
unsigned sign = m_sign; m_sign = other.m_sign; other.m_sign = sign;
unsigned sig_idx = m_sig_idx; m_sig_idx = other.m_sig_idx; other.m_sig_idx = sig_idx;
std::swap(m_exponent, other.m_exponent);
}
};
inline void swap(mpff & m1, mpff & m2) { m1.swap(m2); }
inline void swap(mpff & m1, mpff & m2) noexcept { m1.swap(m2); }
class mpz;
class mpq;
@ -316,7 +316,7 @@ public:
*/
static void abs(mpff & a) { a.m_sign = 0; }
static void swap(mpff & a, mpff & b) { a.swap(b); }
static void swap(mpff & a, mpff & b) noexcept { a.swap(b); }
/**
\brief c <- a + b

View file

@ -38,13 +38,13 @@ public:
m_sig_idx(0) {
}
void swap(mpfx & other) {
void swap(mpfx & other) noexcept {
unsigned sign = m_sign; m_sign = other.m_sign; other.m_sign = sign;
unsigned sig_idx = m_sig_idx; m_sig_idx = other.m_sig_idx; other.m_sig_idx = sig_idx;
}
};
inline void swap(mpfx & m1, mpfx & m2) { m1.swap(m2); }
inline void swap(mpfx & m1, mpfx & m2) noexcept { m1.swap(m2); }
class mpz;
class mpq;
@ -228,7 +228,7 @@ public:
*/
static void abs(mpfx & a) { a.m_sign = 0; }
static void swap(mpfx & a, mpfx & b) { a.swap(b); }
static void swap(mpfx & a, mpfx & b) noexcept { a.swap(b); }
/**
\brief c <- a + b

View file

@ -761,9 +761,9 @@ public:
return temp;
}
void swap(mpz & a, mpz & b) { mpz_manager<SYNCH>::swap(a, b); }
void swap(mpz & a, mpz & b) noexcept { mpz_manager<SYNCH>::swap(a, b); }
void swap(mpq & a, mpq & b) {
void swap(mpq & a, mpq & b) noexcept {
swap(a.m_num, b.m_num);
swap(a.m_den, b.m_den);
}

View file

@ -52,7 +52,7 @@ public:
m.del(a.second);
}
void swap(mpq_inf & a, mpq_inf & b) {
void swap(mpq_inf & a, mpq_inf & b) noexcept {
m.swap(a.first, b.first);
m.swap(a.second, b.second);
}

View file

@ -110,7 +110,7 @@ public:
return *this;
}
void swap(mpz & other) {
void swap(mpz & other) noexcept {
std::swap(m_val, other.m_val);
std::swap(m_ptr, other.m_ptr);
unsigned o = m_owner; m_owner = other.m_owner; other.m_owner = o;
@ -131,7 +131,7 @@ public:
class mpz_stack : public mpz {};
#endif
inline void swap(mpz & m1, mpz & m2) { m1.swap(m2); }
inline void swap(mpz & m1, mpz & m2) noexcept { m1.swap(m2); }
template<bool SYNCH = true>
class mpz_manager {
@ -573,7 +573,7 @@ public:
// deallocates any memory.
void reset(mpz & a);
void swap(mpz & a, mpz & b) {
void swap(mpz & a, mpz & b) noexcept {
std::swap(a.m_val, b.m_val);
std::swap(a.m_ptr, b.m_ptr);
auto o = a.m_owner; a.m_owner = b.m_owner; b.m_owner = o;

View file

@ -183,7 +183,7 @@ public:
}
}
void swap(mpz & a, mpz & b) {
void swap(mpz & a, mpz & b) noexcept {
SASSERT(is_p_normalized(a) && is_p_normalized(b));
m().swap(a, b);
}

View file

@ -81,7 +81,7 @@ public:
m_buffer.reserve(sz);
}
void swap(svector<Numeral> & other) {
void swap(svector<Numeral> & other) noexcept {
m_buffer.swap(other);
}

View file

@ -209,7 +209,7 @@ public:
}
}
void swap(obj_map & other) {
void swap(obj_map & other) noexcept {
m_table.swap(other.m_table);
}
};

View file

@ -93,7 +93,7 @@ public:
return *this;
}
obj_ref & operator=(obj_ref && n) {
obj_ref & operator=(obj_ref && n) noexcept {
SASSERT(&m_manager == &n.m_manager);
std::swap(m_obj, n.m_obj);
n.reset();
@ -105,7 +105,7 @@ public:
m_obj = nullptr;
}
void swap(obj_ref & n) {
void swap(obj_ref & n) noexcept {
std::swap(m_obj, n.m_obj);
}

View file

@ -104,7 +104,7 @@ public:
unsigned long long get_num_collision() const { return m_table.get_num_collision(); }
void swap(obj_ref_map & other) {
void swap(obj_ref_map & other) noexcept {
m_table.swap(other.m_table);
}

View file

@ -94,7 +94,7 @@ public:
return * this;
}
optional & operator=(optional && val) {
optional & operator=(optional && val) noexcept {
std::swap(m_obj, val.m_obj);
return *this;
}

View file

@ -31,7 +31,7 @@ void permutation::reset(unsigned size) {
}
}
void permutation::swap(unsigned i, unsigned j) {
void permutation::swap(unsigned i, unsigned j) noexcept {
unsigned i_prime = m_p[i];
unsigned j_prime = m_p[j];
std::swap(m_p[i], m_p[j]);

View file

@ -31,7 +31,7 @@ public:
unsigned operator()(unsigned i) const { return m_p[i]; }
unsigned inv(unsigned i_prime) const { return m_inv_p[i_prime]; }
void swap(unsigned i, unsigned j);
void swap(unsigned i, unsigned j) noexcept;
void move_after(unsigned i, unsigned j);
void display(std::ostream & out) const;

View file

@ -86,7 +86,7 @@ public:
struct eq_proc { bool operator()(rational const& r1, rational const& r2) const { return r1 == r2; } };
void swap(rational & n) { m().swap(m_val, n.m_val); }
void swap(rational & n) noexcept { m().swap(m_val, n.m_val); }
std::string to_string() const { return m().to_string(m_val); }
@ -671,6 +671,6 @@ inline rational gcd(rational const & r1, rational const & r2, rational & a, rati
return result;
}
inline void swap(rational& r1, rational& r2) {
inline void swap(rational& r1, rational& r2) noexcept {
r1.swap(r2);
}

View file

@ -97,7 +97,7 @@ public:
return *this;
}
ref & operator=(ref &&r) {
ref & operator=(ref &&r) noexcept {
if (this != &r) {
dec_ref ();
m_ptr = r.detach ();
@ -123,7 +123,7 @@ public:
friend bool operator!=(const ref & r1, const ref & r2) {
return r1.m_ptr != r2.m_ptr;
}
friend void swap (ref &r1, ref &r2) {
friend void swap (ref &r1, ref &r2) noexcept {
T* tmp = r1.m_ptr;
r1.m_ptr = r2.m_ptr;
r2.m_ptr = tmp;

View file

@ -143,7 +143,7 @@ public:
push_back(other[i]);
}
void swap(unsigned idx1, unsigned idx2) {
void swap(unsigned idx1, unsigned idx2) noexcept {
std::swap(m_nodes[idx1], m_nodes[idx2]);
}
@ -179,7 +179,7 @@ public:
this->append(other);
}
ref_pair_vector(ref_pair_vector && other) : super(std::move(other)) {}
ref_pair_vector(ref_pair_vector && other) noexcept : super(std::move(other)) {}
ref_pair_vector(TManager & m, unsigned sz, elem_t const * data):
super(ref_manager_wrapper<T, TManager>(m)) {
@ -194,7 +194,7 @@ public:
return get_manager();
}
void swap(ref_pair_vector & other) {
void swap(ref_pair_vector & other) noexcept {
SASSERT(&(this->m_manager) == &(other.m_manager));
this->m_nodes.swap(other.m_nodes);
}

View file

@ -197,14 +197,14 @@ public:
push_back(data[i]);
}
void operator=(ref_vector_core && other) {
void operator=(ref_vector_core && other) noexcept {
if (this != &other) {
reset();
m_nodes = std::move(other.m_nodes);
}
}
void swap(unsigned idx1, unsigned idx2) {
void swap(unsigned idx1, unsigned idx2) noexcept {
std::swap(m_nodes[idx1], m_nodes[idx2]);
}
@ -262,7 +262,7 @@ public:
return get_manager();
}
void swap(ref_vector & other) {
void swap(ref_vector & other) noexcept {
SASSERT(&(this->m_manager) == &(other.m_manager));
this->m_nodes.swap(other.m_nodes);
}

View file

@ -34,7 +34,7 @@ public:
struct hash_proc { unsigned operator()(s_integer const& r) const { return r.hash(); } };
struct eq_proc { bool operator()(s_integer const& r1, s_integer const& r2) const { return r1 == r2; } };
void swap(s_integer & n) {
void swap(s_integer & n) noexcept {
std::swap(m_val, n.m_val);
}

View file

@ -60,11 +60,11 @@ public:
m().reset(m_num);
}
void swap(_scoped_numeral & n) {
void swap(_scoped_numeral & n) noexcept {
m().swap(m_num, n.m_num);
}
void swap(numeral & n) {
void swap(numeral & n) noexcept {
m().swap(m_num, n);
}

View file

@ -34,7 +34,7 @@ public:
scoped_ptr_vector(scoped_ptr_vector&& other) noexcept {
m_vector.swap(other.m_vector);
}
scoped_ptr_vector& operator=(scoped_ptr_vector&& other) {
scoped_ptr_vector& operator=(scoped_ptr_vector&& other) noexcept {
if (this == &other)
return *this;
reset();
@ -55,7 +55,7 @@ public:
dealloc(m_vector[idx]);
m_vector[idx] = ptr;
}
void swap(unsigned i, unsigned j) { std::swap(m_vector[i], m_vector[j]); }
void swap(unsigned i, unsigned j) noexcept { std::swap(m_vector[i], m_vector[j]); }
unsigned size() const { return m_vector.size(); }
bool empty() const { return m_vector.empty(); }
void resize(unsigned sz) {

View file

@ -135,7 +135,7 @@ class tbv_ref {
public:
tbv_ref(tbv_manager& mgr) : mgr(mgr), d(nullptr) {}
tbv_ref(tbv_manager& mgr, tbv* d) : mgr(mgr), d(d) {}
tbv_ref(tbv_ref&& d) : mgr(d.mgr), d(d.detach()) {}
tbv_ref(tbv_ref&& d) noexcept : mgr(d.mgr), d(d.detach()) {}
~tbv_ref() {
if (d) mgr.deallocate(d);
}

View file

@ -28,7 +28,7 @@ public:
typedef unsigned data;
void swap(uint_set & other) {
void swap(uint_set & other) noexcept {
unsigned_vector::swap(other);
}

View file

@ -265,7 +265,7 @@ public:
return *this;
}
scoped_ptr& operator=(scoped_ptr&& other) {
scoped_ptr& operator=(scoped_ptr&& other) noexcept {
*this = other.detach();
return *this;
};
@ -276,7 +276,7 @@ public:
return tmp;
}
void swap(scoped_ptr & p) {
void swap(scoped_ptr & p) noexcept {
std::swap(m_ptr, p.m_ptr);
}
};

View file

@ -330,7 +330,7 @@ public:
return *this;
}
vector & operator=(vector && source) {
vector & operator=(vector && source) noexcept {
if (this == &source) {
return *this;
}