Skip to content

Commit

Permalink
ref/ref_vector minor convenience changes (#5322)
Browse files Browse the repository at this point in the history
* Add ref_vector_core::push_back(ref<T>&&)

* Make operator bool() explicit
  • Loading branch information
JakobR committed May 31, 2021
1 parent 50cf321 commit 46f8b15
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/muz/spacer/spacer_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class lemma {
expr_ref_vector const &get_cube();
void update_cube(pob_ref const &p, expr_ref_vector &cube);

bool has_pob() {return m_pob;}
bool has_pob() {return !!m_pob;}
pob_ref &get_pob() {return m_pob;}
unsigned weakness() {return m_weakness;}

Expand Down
6 changes: 5 additions & 1 deletion src/util/ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ class ref {
return m_ptr;
}

operator bool() const {
explicit operator bool() const {
return m_ptr != nullptr;
}

bool operator!() const {
return m_ptr == nullptr;
}

const T & operator*() const {
return *m_ptr;
}
Expand Down
6 changes: 6 additions & 0 deletions src/util/ref_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Revision History:

#include "util/vector.h"
#include "util/obj_ref.h"
#include "util/ref.h"

/**
\brief Vector of smart pointers.
Expand Down Expand Up @@ -113,6 +114,11 @@ class ref_vector_core : public Ref {
return *this;
}

ref_vector_core& push_back(ref<T>&& n) {
m_nodes.push_back(n.detach());
return *this;
}

void pop_back() {
SASSERT(!m_nodes.empty());
T * n = m_nodes.back();
Expand Down

0 comments on commit 46f8b15

Please sign in to comment.