mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 03:45:51 +00:00
remove unneeded constructors (last round)
This commit is contained in:
parent
44ec259c4c
commit
bb26f219fe
37 changed files with 65 additions and 276 deletions
|
@ -76,7 +76,6 @@ class array_map {
|
|||
public:
|
||||
|
||||
array_map() = default;
|
||||
array_map(array_map&&) noexcept = default;
|
||||
array_map(Plugin const & p) : m_plugin(p) {}
|
||||
|
||||
~array_map() { really_flush(); }
|
||||
|
|
|
@ -27,7 +27,6 @@ Revision History:
|
|||
class hwf {
|
||||
friend class hwf_manager;
|
||||
double value;
|
||||
hwf & operator=(hwf const & other) { UNREACHABLE(); return *this; }
|
||||
uint64_t get_raw() const {
|
||||
uint64_t n;
|
||||
SASSERT(sizeof(n) == sizeof(value));
|
||||
|
@ -35,8 +34,8 @@ class hwf {
|
|||
return n;
|
||||
}
|
||||
|
||||
public:
|
||||
void swap(hwf & other) { double t = value; value = other.value; other.value = t; }
|
||||
public:
|
||||
void swap(hwf & other) { std::swap(value, other.value); }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -68,15 +68,7 @@ class inf_eps_rational {
|
|||
return s;
|
||||
}
|
||||
|
||||
inf_eps_rational():
|
||||
m_infty(),
|
||||
m_r()
|
||||
{}
|
||||
|
||||
inf_eps_rational(const inf_eps_rational & r):
|
||||
m_infty(r.m_infty),
|
||||
m_r(r.m_r)
|
||||
{}
|
||||
inf_eps_rational() = default;
|
||||
|
||||
explicit inf_eps_rational(int n):
|
||||
m_infty(),
|
||||
|
@ -93,8 +85,6 @@ class inf_eps_rational {
|
|||
m_r(r) {
|
||||
}
|
||||
|
||||
~inf_eps_rational() {}
|
||||
|
||||
/**
|
||||
\brief Set inf_eps_rational to 0.
|
||||
*/
|
||||
|
@ -163,13 +153,6 @@ class inf_eps_rational {
|
|||
return inf_eps_rational(rational::one(), Numeral::zero());
|
||||
}
|
||||
|
||||
|
||||
inf_eps_rational & operator=(const inf_eps_rational & r) {
|
||||
m_infty = r.m_infty;
|
||||
m_r = r.m_r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inf_eps_rational & operator=(const Numeral & r) {
|
||||
m_infty.reset();
|
||||
m_r = r;
|
||||
|
|
|
@ -55,11 +55,6 @@ class inf_int_rational {
|
|||
m_second(0)
|
||||
{}
|
||||
|
||||
inf_int_rational(const inf_int_rational & r):
|
||||
m_first(r.m_first),
|
||||
m_second(r.m_second)
|
||||
{}
|
||||
|
||||
explicit inf_int_rational(int n):
|
||||
m_first(rational(n)),
|
||||
m_second(0)
|
||||
|
@ -84,8 +79,6 @@ class inf_int_rational {
|
|||
m_second(i) {
|
||||
}
|
||||
|
||||
~inf_int_rational() {}
|
||||
|
||||
/**
|
||||
\brief Set inf_int_rational to 0.
|
||||
*/
|
||||
|
@ -128,12 +121,6 @@ class inf_int_rational {
|
|||
|
||||
rational const & get_first() const { return m_first; }
|
||||
|
||||
inf_int_rational & operator=(const inf_int_rational & r) {
|
||||
m_first = r.m_first;
|
||||
m_second = r.m_second;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inf_int_rational & operator=(const rational & r) {
|
||||
m_first = r;
|
||||
m_second = 0;
|
||||
|
@ -165,8 +152,6 @@ class inf_int_rational {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inf_int_rational & operator-=(const inf_int_rational & r) {
|
||||
m_first -= r.m_first;
|
||||
m_second -= r.m_second;
|
||||
|
|
|
@ -93,8 +93,6 @@ class inf_rational {
|
|||
m_second(i) {
|
||||
}
|
||||
|
||||
~inf_rational() {}
|
||||
|
||||
/**
|
||||
\brief Set inf_rational to 0.
|
||||
*/
|
||||
|
@ -137,12 +135,6 @@ class inf_rational {
|
|||
|
||||
rational const & get_first() const { return m_first; }
|
||||
|
||||
inf_rational & operator=(const inf_rational & r) {
|
||||
m_first = r.m_first;
|
||||
m_second = r.m_second;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inf_rational & operator=(const rational & r) {
|
||||
m_first = r;
|
||||
m_second.reset();
|
||||
|
|
|
@ -29,7 +29,6 @@ class mpq {
|
|||
public:
|
||||
mpq(int v):m_num(v), m_den(1) {}
|
||||
mpq():m_den(1) {}
|
||||
mpq(mpq &&) = default;
|
||||
mpq & operator=(mpq const &) = delete;
|
||||
void swap(mpq & other) { m_num.swap(other.m_num); m_den.swap(other.m_den); }
|
||||
mpz const & numerator() const { return m_num; }
|
||||
|
|
|
@ -98,16 +98,10 @@ class mpz {
|
|||
friend class mpbq;
|
||||
friend class mpbq_manager;
|
||||
friend class mpz_stack;
|
||||
mpz & operator=(mpz const & other) { UNREACHABLE(); return *this; }
|
||||
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) noexcept : m_val(other.m_val), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {
|
||||
std::swap(m_ptr, other.m_ptr);
|
||||
m_owner = other.m_owner;
|
||||
m_kind = other.m_kind;
|
||||
}
|
||||
void swap(mpz & other) {
|
||||
std::swap(m_val, other.m_val);
|
||||
std::swap(m_ptr, other.m_ptr);
|
||||
|
|
|
@ -83,11 +83,13 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
obj_ref & operator=(obj_ref & n) {
|
||||
obj_ref & operator=(const obj_ref & n) {
|
||||
SASSERT(&m_manager == &n.m_manager);
|
||||
n.inc_ref();
|
||||
dec_ref();
|
||||
m_obj = n.m_obj;
|
||||
if (m_obj != n.m_obj) {
|
||||
dec_ref();
|
||||
m_obj = n.m_obj;
|
||||
inc_ref();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,39 +22,31 @@ Revision History:
|
|||
|
||||
template<class T>
|
||||
class optional {
|
||||
T* m_obj;
|
||||
char m_initialized;
|
||||
|
||||
void construct(const T & val) {
|
||||
m_initialized = 1;
|
||||
m_obj = alloc(T, val);
|
||||
}
|
||||
T* m_obj = nullptr;
|
||||
|
||||
void destroy() {
|
||||
if (m_initialized == 1) {
|
||||
dealloc(m_obj);
|
||||
m_obj = nullptr;
|
||||
}
|
||||
m_initialized = 0;
|
||||
dealloc(m_obj);
|
||||
m_obj = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
optional():
|
||||
m_obj(nullptr), m_initialized(0) {}
|
||||
optional() {}
|
||||
|
||||
explicit optional(const T & val) {
|
||||
construct(val);
|
||||
m_obj = alloc(T, val);
|
||||
}
|
||||
|
||||
optional(T && val) noexcept : m_obj(nullptr), m_initialized(0) {
|
||||
explicit optional(T && val) {
|
||||
m_obj = alloc(T, std::move(val));
|
||||
}
|
||||
|
||||
optional(optional<T> && val) noexcept {
|
||||
std::swap(m_obj, val.m_obj);
|
||||
std::swap(m_initialized, val.m_initialized);
|
||||
}
|
||||
|
||||
optional(const optional<T> & val):
|
||||
m_initialized(0) {
|
||||
if (val.m_initialized == 1) {
|
||||
construct(*val);
|
||||
optional(const optional<T> & val) {
|
||||
if (val.m_obj) {
|
||||
m_obj = alloc(T, *val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,56 +56,54 @@ public:
|
|||
|
||||
static optional const & undef() { static optional u; return u; }
|
||||
|
||||
bool initialized() const { return m_initialized == 1; }
|
||||
operator bool() const { return m_initialized == 1; }
|
||||
bool operator!() const { return m_initialized == 0; }
|
||||
bool initialized() const { return m_obj; }
|
||||
operator bool() const { return m_obj; }
|
||||
bool operator!() const { return !m_obj; }
|
||||
|
||||
T * get() const {
|
||||
if (m_initialized == 1) {
|
||||
return m_obj;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
return m_obj;
|
||||
}
|
||||
|
||||
void set_invalid() {
|
||||
if (m_initialized == 1) {
|
||||
destroy();
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
T * operator->() {
|
||||
SASSERT(m_initialized==1);
|
||||
SASSERT(m_obj);
|
||||
return m_obj;
|
||||
}
|
||||
|
||||
T const * operator->() const {
|
||||
SASSERT(m_initialized==1);
|
||||
SASSERT(m_obj);
|
||||
return m_obj;
|
||||
}
|
||||
|
||||
const T & operator*() const {
|
||||
SASSERT(m_initialized==1);
|
||||
SASSERT(m_obj);
|
||||
return *m_obj;
|
||||
}
|
||||
|
||||
T & operator*() {
|
||||
SASSERT(m_initialized==1);
|
||||
SASSERT(m_obj);
|
||||
return *m_obj;
|
||||
}
|
||||
|
||||
optional & operator=(const T & val) {
|
||||
destroy();
|
||||
construct(val);
|
||||
m_obj = alloc(T, val);
|
||||
return * this;
|
||||
}
|
||||
|
||||
optional & operator=(optional && val) {
|
||||
std::swap(m_obj, val.m_obj);
|
||||
return *this;
|
||||
}
|
||||
|
||||
optional & operator=(const optional & val) {
|
||||
if (&val != this) {
|
||||
destroy();
|
||||
if (val.m_initialized) {
|
||||
construct(*val);
|
||||
if (val.m_obj) {
|
||||
m_obj = alloc(T, *val);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
|
@ -135,8 +125,6 @@ public:
|
|||
optional():m_ptr(nullptr) {}
|
||||
|
||||
explicit optional(T * val):m_ptr(val) {}
|
||||
|
||||
optional(const optional & val):m_ptr(val.m_ptr) {}
|
||||
|
||||
static optional const & undef() { return m_undef; }
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
rational() {}
|
||||
|
||||
rational(rational const & r) { m().set(m_val, r.m_val); }
|
||||
rational(rational&&) = default;
|
||||
rational(rational&&) noexcept = default;
|
||||
|
||||
explicit rational(int n) { m().set(m_val, n); }
|
||||
|
||||
|
@ -131,7 +131,9 @@ public:
|
|||
rational const & get_rational() const { return *this; }
|
||||
|
||||
rational const & get_infinitesimal() const { return m_zero; }
|
||||
|
||||
|
||||
rational & operator=(rational&&) = default;
|
||||
|
||||
rational & operator=(rational const & r) {
|
||||
m().set(m_val, r.m_val);
|
||||
return *this;
|
||||
|
|
|
@ -17,18 +17,19 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#pragma once
|
||||
#include <utility>
|
||||
|
||||
template<typename T>
|
||||
class ref {
|
||||
T * m_ptr;
|
||||
|
||||
void inc_ref() {
|
||||
void inc_ref() {
|
||||
if (m_ptr) {
|
||||
m_ptr->inc_ref();
|
||||
}
|
||||
}
|
||||
|
||||
void dec_ref() {
|
||||
void dec_ref() {
|
||||
if (m_ptr) {
|
||||
m_ptr->dec_ref();
|
||||
}
|
||||
|
@ -49,7 +50,10 @@ public:
|
|||
inc_ref();
|
||||
}
|
||||
|
||||
ref (ref && r): m_ptr (r.detach ()) {}
|
||||
ref (ref && r) noexcept : m_ptr(nullptr) {
|
||||
std::swap(m_ptr, r.m_ptr);
|
||||
}
|
||||
|
||||
~ref() {
|
||||
dec_ref();
|
||||
}
|
||||
|
|
|
@ -49,14 +49,10 @@ public:
|
|||
|
||||
ref_pair_vector_core(Ref const & r = Ref()):Ref(r) {}
|
||||
|
||||
ref_pair_vector_core(ref_pair_vector_core && other) :
|
||||
Ref(std::move(other)),
|
||||
m_nodes(std::move(other.m_nodes)) {}
|
||||
|
||||
~ref_pair_vector_core() {
|
||||
dec_range_ref(m_nodes.begin(), m_nodes.end());
|
||||
}
|
||||
|
||||
|
||||
void reset() {
|
||||
dec_range_ref(m_nodes.begin(), m_nodes.end());
|
||||
m_nodes.reset();
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
append(other);
|
||||
}
|
||||
|
||||
ref_vector_core(ref_vector_core &&) = default;
|
||||
ref_vector_core(ref_vector_core &&) noexcept = default;
|
||||
|
||||
~ref_vector_core() {
|
||||
dec_range_ref(m_nodes.begin(), m_nodes.end());
|
||||
|
@ -241,7 +241,7 @@ public:
|
|||
this->append(other);
|
||||
}
|
||||
|
||||
ref_vector(ref_vector &&) = default;
|
||||
ref_vector(ref_vector &&) noexcept = default;
|
||||
|
||||
ref_vector(TManager & m, unsigned sz, T * const * data):
|
||||
super(ref_manager_wrapper<T, TManager>(m)) {
|
||||
|
@ -324,8 +324,10 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
// prevent abuse:
|
||||
ref_vector & operator=(ref_vector const & other) = delete;
|
||||
ref_vector & operator=(ref_vector const & other) {
|
||||
set(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ref_vector & operator=(ref_vector && other) = default;
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ public:
|
|||
|
||||
public:
|
||||
s_integer(): m_val(0) {}
|
||||
s_integer(const s_integer & r):m_val(r.m_val) {}
|
||||
explicit s_integer(int n):m_val(n) {}
|
||||
struct i64 {};
|
||||
explicit s_integer(int64_t i, i64):m_val(static_cast<int>(i)) {}
|
||||
|
@ -67,7 +66,6 @@ public:
|
|||
s_integer const& get_infinitesimal() const { return zero(); }
|
||||
static bool is_rational() { return true; }
|
||||
s_integer const& get_rational() const { return *this; }
|
||||
s_integer & operator=(const s_integer & r) { m_val = r.m_val; return *this; }
|
||||
friend inline s_integer numerator(const s_integer & r) { return r; }
|
||||
friend inline s_integer denominator(const s_integer & r) { return one(); }
|
||||
s_integer & operator+=(const s_integer & r) { m_val += r.m_val; return *this; }
|
||||
|
|
|
@ -58,17 +58,6 @@ public:
|
|||
stacked_value(const T&& m) {
|
||||
m_value = std::move(m);
|
||||
}
|
||||
|
||||
T& operator=(T arg) { // copy/move constructor
|
||||
m_value = arg;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
stacked_value& operator=(stacked_value const& other) {
|
||||
m_value = other.m_value;
|
||||
m_stack = other.m_stack;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator T&() {
|
||||
return m_value;
|
||||
|
|
|
@ -198,12 +198,6 @@ public:
|
|||
bool operator!=(iterator const& it) const { return m_index != it.m_index; }
|
||||
iterator & operator++() { ++m_index; scan(); return *this; }
|
||||
iterator operator++(int) { iterator tmp = *this; ++*this; return tmp; }
|
||||
iterator & operator=(iterator const& other) {
|
||||
m_set = other.m_set;
|
||||
m_index = other.m_index;
|
||||
m_last = other.m_last;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
iterator const begin() const { return iterator(*this, false); }
|
||||
|
@ -267,12 +261,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
tracked_uint_set& operator=(tracked_uint_set const& other) {
|
||||
m_in_set = other.m_in_set;
|
||||
m_set = other.m_set;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool contains(unsigned v) const {
|
||||
return v < m_in_set.size() && m_in_set[v] != 0;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class vector {
|
|||
m_data = reinterpret_cast<T *>(mem);
|
||||
}
|
||||
else {
|
||||
//static_assert(std::is_nothrow_move_constructible<T>::value, "");
|
||||
static_assert(std::is_nothrow_move_constructible<T>::value, "");
|
||||
SASSERT(capacity() > 0);
|
||||
SZ old_capacity = reinterpret_cast<SZ *>(m_data)[CAPACITY_IDX];
|
||||
SZ old_capacity_T = sizeof(T) * old_capacity + sizeof(SZ) * 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue