Skip to content

Commit

Permalink
add == for const_ref and ref to disambiguate equality.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Oct 2, 2024
1 parent c7af973 commit 93ff89b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/math/lp/stacked_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ template < typename B> class stacked_vector {
operator const B&() const {
return m_vec.m_vector[m_i];
}

bool operator==(B const& other) const {
return m_vec.m_vector[m_i] == other;
}
bool operator!=(B const& other) const {
return m_vec.m_vector[m_i] != other;
}
bool operator==(ref const& other) const {
return m_vec.m_vector[m_i] == other.m_vec.m_vector[other.m_i];
}
bool operator!=(ref const& other) const {
return m_vec.m_vector[m_i] != other.m_vec.m_vectpr[other.m_i];
}


B& operator+=(B const &delta) {
// not tracking the change here!
return m_vec.m_vector[m_i] += delta;
Expand All @@ -74,12 +82,16 @@ template < typename B> class stacked_vector {
public:
ref_const(const stacked_vector<B> &m, unsigned key) :m_vec(m), m_i(key) {
lp_assert(key < m.size());
}

}
operator const B&() const {
return m_vec.m_vector[m_i];
}

bool operator==(ref_const const& other) const {
return m_vec.m_vector[m_i] == other.m_vec.m_vector[other.m_i];
}
bool operator!=(ref_const const& other) const {
return m_vec.m_vector[m_i] != other.m_vec.m_vectpr[other.m_i];
}
};

private:
Expand Down

0 comments on commit 93ff89b

Please sign in to comment.