diff options
Diffstat (limited to 'impl/VariableAssignment.hpp')
-rw-r--r-- | impl/VariableAssignment.hpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/impl/VariableAssignment.hpp b/impl/VariableAssignment.hpp index a2d0afd..c0c7148 100644 --- a/impl/VariableAssignment.hpp +++ b/impl/VariableAssignment.hpp @@ -36,13 +36,13 @@ struct VariableAssignment { return *this; } const T& operator[] (const Variable<T>& x) const { - if (x.id() < 0 || x.id() >= _length) { + if (x.id() >= _length) { throw "Array out of bounds"; } return _assignment[x.id()]; } T& operator[] (const Variable<T>& x) { - if (x.id() < 0 || x.id() >= _length) { + if (x.id() >= _length) { throw "Array out of bounds"; } return _assignment[x.id()]; @@ -62,6 +62,20 @@ struct VariableAssignment { } return expansion; } + + bool operator==(const VariableAssignment& other) const { + if (_length != other._length) + return false; + for (unsigned int i = 0; i < _length; ++i) { + if (_assignment[i] != other._assignment[i]) { + return false; + } + } + return true; + } + bool operator!=(const VariableAssignment& other) const { + return !(*this == other); + } private: unsigned int _length; T* _assignment; |