Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref/ref_vector minor convenience changes #5322

Merged
merged 2 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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