Skip to content

Commit 93ff89b

Browse files
add == for const_ref and ref to disambiguate equality.
1 parent c7af973 commit 93ff89b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/math/lp/stacked_vector.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ template < typename B> class stacked_vector {
5151
operator const B&() const {
5252
return m_vec.m_vector[m_i];
5353
}
54-
54+
5555
bool operator==(B const& other) const {
5656
return m_vec.m_vector[m_i] == other;
5757
}
5858
bool operator!=(B const& other) const {
5959
return m_vec.m_vector[m_i] != other;
6060
}
61+
bool operator==(ref const& other) const {
62+
return m_vec.m_vector[m_i] == other.m_vec.m_vector[other.m_i];
63+
}
64+
bool operator!=(ref const& other) const {
65+
return m_vec.m_vector[m_i] != other.m_vec.m_vectpr[other.m_i];
66+
}
67+
68+
6169
B& operator+=(B const &delta) {
6270
// not tracking the change here!
6371
return m_vec.m_vector[m_i] += delta;
@@ -74,12 +82,16 @@ template < typename B> class stacked_vector {
7482
public:
7583
ref_const(const stacked_vector<B> &m, unsigned key) :m_vec(m), m_i(key) {
7684
lp_assert(key < m.size());
77-
}
78-
85+
}
7986
operator const B&() const {
8087
return m_vec.m_vector[m_i];
8188
}
82-
89+
bool operator==(ref_const const& other) const {
90+
return m_vec.m_vector[m_i] == other.m_vec.m_vector[other.m_i];
91+
}
92+
bool operator!=(ref_const const& other) const {
93+
return m_vec.m_vector[m_i] != other.m_vec.m_vectpr[other.m_i];
94+
}
8395
};
8496

8597
private:

0 commit comments

Comments
 (0)