Skip to content

Commit

Permalink
Use = delete to delete special methods.
Browse files Browse the repository at this point in the history
This provides a better experience than just marking them as
private and leaving them as undefined symbols.
  • Loading branch information
waywardmonkeys authored and NikolajBjorner committed Aug 2, 2022
1 parent 059b795 commit 82d853e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/ast/pattern/pattern_inference.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class smaller_pattern {
void save(expr * p1, expr * p2);
bool process(expr * p1, expr * p2);

smaller_pattern & operator=(smaller_pattern const &);

public:

smaller_pattern(ast_manager & m):
m(m) {
}

smaller_pattern & operator=(smaller_pattern const &) = delete;

bool operator()(unsigned num_bindings, expr * p1, expr * p2);
};

Expand Down
6 changes: 2 additions & 4 deletions src/muz/base/dl_costs.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ namespace datalog {
bool passes_output_thresholds(context & ctx) const;
void output_profile(std::ostream & out) const;

private:
//private and undefined copy constructor and operator= to avoid the default ones
accounted_object(const accounted_object &);
accounted_object& operator=(const accounted_object &);
accounted_object(const accounted_object &) = delete;
accounted_object& operator=(const accounted_object &) = delete;
};


Expand Down
6 changes: 2 additions & 4 deletions src/muz/base/dl_rule_subsumption_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ Revision History:
namespace datalog {

class rule_subsumption_index {
//private and undefined copy constroctor
rule_subsumption_index(rule_subsumption_index const&);
//private and undefined operator=
rule_subsumption_index& operator=(rule_subsumption_index const&);

typedef obj_hashtable<app> app_set;

Expand All @@ -53,6 +49,8 @@ namespace datalog {
reset_dealloc_values(m_unconditioned_heads);
}

rule_subsumption_index(rule_subsumption_index const&) = delete;
rule_subsumption_index& operator=(rule_subsumption_index const&) = delete;
void add(rule * r);
bool is_subsumed(rule * r);
bool is_subsumed(app * query);
Expand Down
21 changes: 9 additions & 12 deletions src/muz/rel/dl_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,9 @@ namespace datalog {
public:
base_fn() = default;
virtual ~base_fn() {}
private:
//private and undefined copy constructor and operator= to avoid copying
base_fn(const base_fn &);
base_fn& operator=(const base_fn &);

base_fn(const base_fn &) = delete;
base_fn& operator=(const base_fn &) = delete;
};

class join_fn : public base_fn {
Expand Down Expand Up @@ -1098,6 +1097,9 @@ namespace datalog {
iterator_core() : m_ref_cnt(0) {}
virtual ~iterator_core() {}

iterator_core(const iterator_core &) = delete;
iterator_core & operator=(const iterator_core &) = delete;

void inc_ref() { m_ref_cnt++; }
void dec_ref() {
SASSERT(m_ref_cnt>0);
Expand All @@ -1116,10 +1118,6 @@ namespace datalog {
//the equality with the end() iterator
return is_finished() && it.is_finished();
}
private:
//private and undefined copy constructor and assignment operator
iterator_core(const iterator_core &);
iterator_core & operator=(const iterator_core &);
};

struct row_iterator_core {
Expand All @@ -1128,6 +1126,9 @@ namespace datalog {
row_iterator_core() : m_ref_cnt(0) {}
virtual ~row_iterator_core() {}

row_iterator_core(const row_iterator_core &) = delete;
row_iterator_core & operator=(const row_iterator_core &) = delete;

void inc_ref() { m_ref_cnt++; }
void dec_ref() {
SASSERT(m_ref_cnt>0);
Expand All @@ -1146,10 +1147,6 @@ namespace datalog {
//the equality with the end() iterator
return is_finished() && it.is_finished();
}
private:
//private and undefined copy constructor and assignment operator
row_iterator_core(const row_iterator_core &);
row_iterator_core & operator=(const row_iterator_core &);
};

public:
Expand Down
3 changes: 1 addition & 2 deletions src/muz/rel/dl_mk_simple_joins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace datalog {

pair_info() {}

pair_info & operator=(const pair_info &) = delete;
bool can_be_joined() const {
return m_consumers > 0;
}
Expand Down Expand Up @@ -110,8 +111,6 @@ namespace datalog {
SASSERT(!m_rules.empty() || m_consumers == 0);
return m_rules.empty();
}
private:
pair_info & operator=(const pair_info &); //to avoid the implicit one
};
typedef std::pair<app*, app*> app_pair;
typedef pair_hash<obj_ptr_hash<app>, obj_ptr_hash<app> > app_pair_hash;
Expand Down
4 changes: 2 additions & 2 deletions src/muz/transforms/dl_mk_slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ namespace datalog {
rule_unifier m_unifier;


slice_proof_converter(slice_proof_converter const& other);

void init_form2rule() {
if (!m_sliceform2rule.empty()) {
return;
Expand Down Expand Up @@ -271,6 +269,8 @@ namespace datalog {
m_renaming.insert(orig_rule, unsigned_vector(sz, renaming));
}

slice_proof_converter(slice_proof_converter const& other) = delete;

proof_ref operator()(ast_manager& m, unsigned num_source, proof * const * source) override {
SASSERT(num_source == 1);
proof_ref result(source[0], m);
Expand Down
4 changes: 2 additions & 2 deletions src/util/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class array {

char * raw_ptr() const { return reinterpret_cast<char*>(reinterpret_cast<size_t*>(m_data) - 1); }

array & operator=(array const & source);

void set_data(void * mem, unsigned sz) {
size_t * _mem = static_cast<size_t*>(mem);
*_mem = sz;
Expand Down Expand Up @@ -115,6 +113,8 @@ class array {
destroy_elements();
}

array & operator=(array const & source) = delete;

// Free the memory used to store the array.
template<typename Allocator>
void finalize(Allocator & a) {
Expand Down
3 changes: 2 additions & 1 deletion src/util/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ class params_ref {
params * m_params;
void init();
void copy_core(params const * p);
params_ref& operator=(params_ref const& p) = delete;
void set(params_ref const& p);
public:
params_ref():m_params(nullptr) {}
params_ref(params_ref const & p);
~params_ref();

params_ref& operator=(params_ref const& p) = delete;

static params_ref const & get_empty() { return g_empty_params_ref; }


Expand Down
3 changes: 2 additions & 1 deletion src/util/scoped_numeral_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ template<typename Manager, unsigned INITIAL_SIZE = 16>
class _scoped_numeral_buffer : public sbuffer<typename Manager::numeral, INITIAL_SIZE> {
typedef sbuffer<typename Manager::numeral, INITIAL_SIZE> super;
Manager & m_manager;
_scoped_numeral_buffer(_scoped_numeral_buffer const & v);
public:
_scoped_numeral_buffer(Manager & m):m_manager(m) {}
~_scoped_numeral_buffer() {
reset();
}

_scoped_numeral_buffer(_scoped_numeral_buffer const & v) = delete;

void reset() {
unsigned sz = this->size();
for (unsigned i = 0; i < sz; i++) {
Expand Down

0 comments on commit 82d853e

Please sign in to comment.