mirror of
https://github.com/Z3Prover/z3
synced 2025-04-07 18:05:21 +00:00
remove unneeded constructors (last round)
This commit is contained in:
parent
44ec259c4c
commit
bb26f219fe
|
@ -264,7 +264,6 @@ public:
|
|||
unsigned num_parameters = 0, parameter const * parameters = nullptr, bool private_params = false);
|
||||
|
||||
decl_info(decl_info const& other);
|
||||
~decl_info() {}
|
||||
|
||||
void init_eh(ast_manager & m);
|
||||
void del_eh(ast_manager & m);
|
||||
|
@ -314,7 +313,6 @@ class sort_size {
|
|||
public:
|
||||
sort_size():m_kind(SS_INFINITE) {}
|
||||
sort_size(uint64_t const & sz):m_kind(SS_FINITE), m_size(sz) {}
|
||||
sort_size(sort_size const& other): m_kind(other.m_kind), m_size(other.m_size) {}
|
||||
explicit sort_size(rational const& r) {
|
||||
if (r.is_uint64()) {
|
||||
m_kind = SS_FINITE;
|
||||
|
@ -371,8 +369,6 @@ public:
|
|||
sort_info(decl_info const& di, sort_size const& num_elements) :
|
||||
decl_info(di), m_num_elements(num_elements) {}
|
||||
|
||||
~sort_info() {}
|
||||
|
||||
bool is_infinite() const { return m_num_elements.is_infinite(); }
|
||||
bool is_very_big() const { return m_num_elements.is_very_big(); }
|
||||
sort_size const & get_num_elements() const { return m_num_elements; }
|
||||
|
@ -403,7 +399,6 @@ struct func_decl_info : public decl_info {
|
|||
bool m_lambda:1;
|
||||
|
||||
func_decl_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind, unsigned num_parameters = 0, parameter const * parameters = nullptr);
|
||||
~func_decl_info() {}
|
||||
|
||||
bool is_associative() const { return m_left_assoc && m_right_assoc; }
|
||||
bool is_left_associative() const { return m_left_assoc; }
|
||||
|
|
|
@ -70,16 +70,12 @@ public:
|
|||
m_lower_bound_witness(UINT_MAX),
|
||||
m_upper_bound_witness(UINT_MAX),
|
||||
m_associated_with_row(false) {}
|
||||
|
||||
|
||||
ul_pair(bool associated_with_row) :
|
||||
m_lower_bound_witness(UINT_MAX),
|
||||
m_upper_bound_witness(UINT_MAX),
|
||||
m_associated_with_row(associated_with_row) {}
|
||||
|
||||
ul_pair(const ul_pair & o):
|
||||
m_lower_bound_witness(o.m_lower_bound_witness),
|
||||
m_upper_bound_witness(o.m_upper_bound_witness),
|
||||
m_associated_with_row(o.m_associated_with_row) {}
|
||||
|
||||
bool associated_with_row() const { return m_associated_with_row; }
|
||||
};
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ namespace datalog {
|
|||
struct uint_set2 {
|
||||
uint_set lt;
|
||||
uint_set le;
|
||||
uint_set2(uint_set2 const& other):lt(other.lt), le(other.le) {}
|
||||
uint_set2() {}
|
||||
bool operator==(const uint_set2& other) const {
|
||||
return other.lt == lt && other.le == le;
|
||||
|
@ -120,7 +119,6 @@ namespace datalog {
|
|||
|
||||
public:
|
||||
bound_relation(bound_relation_plugin& p, relation_signature const& s, bool is_empty);
|
||||
bound_relation& operator=(bound_relation const& other);
|
||||
|
||||
bool empty() const override { return m_empty; }
|
||||
void add_fact(const relation_fact & f) override;
|
||||
|
|
|
@ -442,10 +442,6 @@ derivation::premise::premise (pred_transformer &pt, unsigned oidx,
|
|||
m_ovars.push_back(m.mk_const(sm.n2o(v->get_decl(), m_oidx)));
|
||||
}
|
||||
|
||||
derivation::premise::premise (const derivation::premise &p) :
|
||||
m_pt (p.m_pt), m_oidx (p.m_oidx), m_summary (p.m_summary), m_must (p.m_must),
|
||||
m_ovars (p.m_ovars) {}
|
||||
|
||||
/// \brief Updated the summary.
|
||||
/// The new summary is over n-variables.
|
||||
void derivation::premise::set_summary (expr * summary, bool must,
|
||||
|
|
|
@ -756,7 +756,6 @@ class derivation {
|
|||
public:
|
||||
premise (pred_transformer &pt, unsigned oidx, expr *summary, bool must,
|
||||
const ptr_vector<app> *aux_vars = nullptr);
|
||||
premise (const premise &p);
|
||||
|
||||
bool is_must() {return m_must;}
|
||||
expr * get_summary() {return m_summary.get ();}
|
||||
|
|
|
@ -47,7 +47,6 @@ struct relation_info {
|
|||
expr_ref m_body;
|
||||
relation_info(ast_manager& m, func_decl* pred, ptr_vector<func_decl> const& vars, expr* b):
|
||||
m_pred(pred, m), m_vars(m, vars.size(), vars.c_ptr()), m_body(b, m) {}
|
||||
relation_info(relation_info const& other): m_pred(other.m_pred), m_vars(other.m_vars), m_body(other.m_body) {}
|
||||
};
|
||||
|
||||
class unknown_exception {};
|
||||
|
|
|
@ -60,12 +60,6 @@ namespace datalog {
|
|||
|
||||
mk_karr_invariants::~mk_karr_invariants() { }
|
||||
|
||||
matrix& matrix::operator=(matrix const& other) {
|
||||
reset();
|
||||
append(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void matrix::display_row(
|
||||
std::ostream& out, vector<rational> const& row, rational const& b, bool is_eq) {
|
||||
for (unsigned j = 0; j < row.size(); ++j) {
|
||||
|
|
|
@ -36,7 +36,6 @@ namespace datalog {
|
|||
bool_vector eq;
|
||||
unsigned size() const { return A.size(); }
|
||||
void reset() { A.reset(); b.reset(); eq.reset(); }
|
||||
matrix& operator=(matrix const& other);
|
||||
void append(matrix const& other) { A.append(other.A); b.append(other.b); eq.append(other.eq); }
|
||||
void display(std::ostream& out) const;
|
||||
static void display_row(
|
||||
|
|
|
@ -374,7 +374,7 @@ namespace opt {
|
|||
smt::theory_var v = get_optimizer().add_objective(term);
|
||||
TRACE("opt", tout << v << " " << mk_pp(term, m) << "\n";);
|
||||
m_objective_vars.push_back(v);
|
||||
m_objective_values.push_back(inf_eps(rational(-1), inf_rational()));
|
||||
m_objective_values.push_back(inf_eps(rational::minus_one(), inf_rational()));
|
||||
m_objective_terms.push_back(term);
|
||||
m_valid_objectives.push_back(true);
|
||||
m_models.push_back(nullptr);
|
||||
|
|
|
@ -229,10 +229,8 @@ namespace qe {
|
|||
class def_vector {
|
||||
func_decl_ref_vector m_vars;
|
||||
expr_ref_vector m_defs;
|
||||
def_vector& operator=(def_vector const& other);
|
||||
public:
|
||||
def_vector(ast_manager& m): m_vars(m), m_defs(m) {}
|
||||
def_vector(def_vector const& other): m_vars(other.m_vars), m_defs(other.m_defs) {}
|
||||
void push_back(func_decl* v, expr* e) {
|
||||
m_vars.push_back(v);
|
||||
m_defs.push_back(e);
|
||||
|
|
|
@ -163,16 +163,6 @@ namespace sat {
|
|||
public:
|
||||
explicit clause_wrapper(literal l1, literal l2):m_l1_idx(l1.to_uint()), m_l2_idx(l2.to_uint()) {}
|
||||
explicit clause_wrapper(clause & c):m_cls(&c), m_l2_idx(null_literal.to_uint()) {}
|
||||
clause_wrapper& operator=(clause_wrapper const& other) {
|
||||
if (other.is_binary()) {
|
||||
m_l1_idx = other.m_l1_idx;
|
||||
}
|
||||
else {
|
||||
m_cls = other.m_cls;
|
||||
}
|
||||
m_l2_idx = other.m_l2_idx;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_binary() const { return m_l2_idx != null_literal.to_uint(); }
|
||||
unsigned size() const { return is_binary() ? 2 : m_cls->size(); }
|
||||
|
|
|
@ -50,19 +50,6 @@ namespace sat {
|
|||
m_elems[1] = m_elems[2] = m_elems[3] = m_elems[4] = 0;
|
||||
}
|
||||
|
||||
cut(cut const& other) {
|
||||
*this = other;
|
||||
}
|
||||
|
||||
cut& operator=(cut const& other) {
|
||||
m_filter = other.m_filter;
|
||||
m_size = other.m_size;
|
||||
m_table = other.m_table;
|
||||
m_dont_care = other.m_dont_care;
|
||||
for (unsigned i = 0; i < m_size; ++i) m_elems[i] = other.m_elems[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
cut_val eval(cut_eval const& env) const;
|
||||
|
||||
unsigned size() const { return m_size; }
|
||||
|
|
|
@ -176,12 +176,6 @@ namespace sat {
|
|||
for (unsigned i = 0; i < v.size(); ++i) insert(v[i]);
|
||||
return *this;
|
||||
}
|
||||
literal_set& operator=(literal_set const& other) {
|
||||
if (this != &other) {
|
||||
m_set = other.m_set;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void insert(literal l) { m_set.insert(l.index()); }
|
||||
void remove(literal l) { m_set.remove(l.index()); }
|
||||
|
|
|
@ -41,10 +41,6 @@ namespace smt {
|
|||
b_justification():
|
||||
m_data(reinterpret_cast<void*>(static_cast<size_t>(AXIOM))) {}
|
||||
|
||||
b_justification(b_justification const & source):
|
||||
m_data(source.m_data) {
|
||||
}
|
||||
|
||||
explicit b_justification(clause * c):
|
||||
m_data(TAG(void*, c, CLAUSE)) {
|
||||
}
|
||||
|
|
|
@ -157,18 +157,6 @@ namespace smt {
|
|||
|
||||
eq(unsigned id, expr_ref_vector& l, expr_ref_vector& r, dependency* d):
|
||||
m_id(id), m_lhs(l), m_rhs(r), m_dep(d) {}
|
||||
eq(eq const& other): m_id(other.m_id), m_lhs(other.m_lhs), m_rhs(other.m_rhs), m_dep(other.m_dep) {}
|
||||
eq& operator=(eq const& other) {
|
||||
if (this != &other) {
|
||||
m_lhs.reset();
|
||||
m_rhs.reset();
|
||||
m_lhs.append(other.m_lhs);
|
||||
m_rhs.append(other.m_rhs);
|
||||
m_dep = other.m_dep;
|
||||
m_id = other.m_id;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
expr_ref_vector const& ls() const { return m_lhs; }
|
||||
expr_ref_vector const& rs() const { return m_rhs; }
|
||||
dependency* dep() const { return m_dep; }
|
||||
|
@ -205,21 +193,6 @@ namespace smt {
|
|||
m_dep(dep) {
|
||||
}
|
||||
|
||||
ne(ne const& other):
|
||||
m_l(other.m_l), m_r(other.m_r),
|
||||
m_eqs(other.m_eqs),
|
||||
m_lits(other.m_lits), m_dep(other.m_dep) {}
|
||||
|
||||
ne& operator=(ne const& other) {
|
||||
if (this != &other) {
|
||||
m_l = other.m_l;
|
||||
m_r = other.m_r;
|
||||
m_eqs.reset(); m_eqs.append(other.m_eqs);
|
||||
m_lits.reset(); m_lits.append(other.m_lits);
|
||||
m_dep = other.m_dep;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
vector<decomposed_eq> const& eqs() const { return m_eqs; }
|
||||
decomposed_eq const& operator[](unsigned i) const { return m_eqs[i]; }
|
||||
|
||||
|
@ -239,18 +212,7 @@ namespace smt {
|
|||
m_contains(c),
|
||||
m_len_gt(len_gt),
|
||||
m_dep(dep) {}
|
||||
nc(nc const& other):
|
||||
m_contains(other.m_contains),
|
||||
m_len_gt(other.m_len_gt),
|
||||
m_dep(other.m_dep) {}
|
||||
nc& operator=(nc const& other) {
|
||||
if (this != &other) {
|
||||
m_contains = other.m_contains;
|
||||
m_dep = other.m_dep;
|
||||
m_len_gt = other.m_len_gt;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
dependency* deps() const { return m_dep; }
|
||||
expr_ref const& contains() const { return m_contains; }
|
||||
literal len_gt() const { return m_len_gt; }
|
||||
|
|
|
@ -212,11 +212,6 @@ public:
|
|||
eautomaton * get_automaton() const { return aut; }
|
||||
expr * get_regex_term() const { return re_term; }
|
||||
bool get_polarity() const { return polarity; }
|
||||
|
||||
virtual ~regex_automaton_under_assumptions() {
|
||||
// don't free str_in_re or aut;
|
||||
// they are managed separately
|
||||
}
|
||||
};
|
||||
|
||||
class char_union_find {
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace smt {
|
|||
m_data(nullptr) {
|
||||
}
|
||||
|
||||
watch_list(watch_list && other) : m_data(nullptr) {
|
||||
watch_list(watch_list && other) noexcept : m_data(nullptr) {
|
||||
std::swap(m_data, other.m_data);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,9 +173,6 @@ class parallel_tactic : public tactic {
|
|||
cube_var(expr_ref_vector const& c, expr_ref_vector const& vs):
|
||||
m_vars(vs), m_cube(c) {}
|
||||
|
||||
cube_var(cube_var const& other):
|
||||
m_vars(other.m_vars), m_cube(other.m_cube) {}
|
||||
|
||||
cube_var operator()(ast_translation& tr) {
|
||||
expr_ref_vector vars(tr(m_vars));
|
||||
expr_ref_vector cube(tr(m_cube));
|
||||
|
|
|
@ -38,15 +38,6 @@ public:
|
|||
lbool is_sat;
|
||||
expr_ref optimum;
|
||||
optimization_result(ast_manager & m) : is_sat(l_undef), optimum(m) {}
|
||||
optimization_result& operator=(optimization_result const& other) {
|
||||
is_sat = other.is_sat;
|
||||
optimum = other.optimum;
|
||||
return *this;
|
||||
}
|
||||
optimization_result(optimization_result const& other):
|
||||
is_sat(other.is_sat),
|
||||
optimum(other.optimum) {
|
||||
}
|
||||
};
|
||||
|
||||
optimization_result optimize(expr_ref const & objective, model_ref initial_model = model_ref(), bool maximize=true);
|
||||
|
|
|
@ -37,27 +37,10 @@ class sls_tracker {
|
|||
unsigned m_random_bits;
|
||||
unsigned m_random_bits_cnt;
|
||||
mpz m_zero, m_one, m_two;
|
||||
|
||||
struct value_score {
|
||||
|
||||
struct value_score {
|
||||
value_score() : m(nullptr), value(unsynch_mpz_manager::mk_z(0)), score(0.0), score_prune(0.0), has_pos_occ(0), has_neg_occ(0), distance(0), touched(1) {};
|
||||
value_score(value_score && other) :
|
||||
m(other.m),
|
||||
value(std::move(other.value)),
|
||||
score(other.score),
|
||||
score_prune(other.score_prune),
|
||||
has_pos_occ(other.has_pos_occ),
|
||||
has_neg_occ(other.has_neg_occ),
|
||||
distance(other.distance),
|
||||
touched(other.touched) {}
|
||||
~value_score() { if (m) m->del(value); }
|
||||
void operator=(value_score && other) {
|
||||
this->~value_score();
|
||||
new (this) value_score(std::move(other));
|
||||
}
|
||||
value_score& operator=(value_score& other) {
|
||||
UNREACHABLE();
|
||||
return *this;
|
||||
}
|
||||
unsynch_mpz_manager * m;
|
||||
mpz value;
|
||||
double score;
|
||||
|
|
|
@ -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…
Reference in a new issue