diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-19 22:54:35 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-19 22:54:35 +0800 |
commit | 75648d51a184fa2936f62fbb82ba399c0b83d7d0 (patch) | |
tree | 454ed9e2c7416b9c489e7581f22221f498966d57 | |
parent | 1feea41ee0c04bc51497f255a5ebef5a18896241 (diff) | |
download | mrust-75648d51a184fa2936f62fbb82ba399c0b83d7d0.tar.gz |
Common - Useful helper for some of the typecheck changes
-rw-r--r-- | src/common.hpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/common.hpp b/src/common.hpp index 7f7dbcb7..bea299bf 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -133,11 +133,34 @@ struct LList const LList* m_prev; T m_item; + LList(): + m_prev(nullptr) + {} LList(const LList* prev, T item): m_prev(prev), m_item( ::std::move(item) ) { - }; + } + + LList end() const { + return LList(); + } + LList begin() const { + return *this; + } + bool operator==(const LList& x) { + return m_prev == x.m_prev; + } + bool operator!=(const LList& x) { + return m_prev != x.m_prev; + } + void operator++() { + assert(m_prev); + *this = *m_prev; + } + const T& operator*() const { + return m_item; + } }; template<typename T> |