aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rtlil.h
diff options
context:
space:
mode:
authorJakob Wenzel <wenzel@rs.tu-darmstadt.de>2019-07-24 13:33:07 +0200
committerJakob Wenzel <wenzel@rs.tu-darmstadt.de>2019-07-24 16:35:40 +0200
commit25685a9a5b20c7c03b02d67f0a029702f0019e9d (patch)
treeab5474e179059e5af8d0be0ef2e550cf7f22f340 /kernel/rtlil.h
parenta66f17b6a78af8f6989235f0c72d5548b0560a58 (diff)
downloadyosys-25685a9a5b20c7c03b02d67f0a029702f0019e9d.tar.gz
yosys-25685a9a5b20c7c03b02d67f0a029702f0019e9d.tar.bz2
yosys-25685a9a5b20c7c03b02d67f0a029702f0019e9d.zip
made ObjectIterator extend std::iterator
this makes it possible to use std algorithms on them
Diffstat (limited to 'kernel/rtlil.h')
-rw-r--r--kernel/rtlil.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 82cbfaf28..10225cff2 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -420,7 +420,11 @@ namespace RTLIL
// It maintains a reference counter that is used to make sure that the container is not modified while being iterated over.
template<typename T>
- struct ObjIterator
+ struct ObjIterator : public std::iterator<std::forward_iterator_tag,
+ T,
+ ptrdiff_t,
+ T *,
+ T &>
{
typename dict<RTLIL::IdString, T>::iterator it;
dict<RTLIL::IdString, T> *list_p;
@@ -474,13 +478,25 @@ namespace RTLIL
return it != other.it;
}
- inline void operator++() {
+
+ inline bool operator==(const RTLIL::ObjIterator<T> &other) const {
+ return !(*this != other);
+ }
+
+ inline ObjIterator<T>& operator++() {
log_assert(list_p != nullptr);
if (++it == list_p->end()) {
(*refcount_p)--;
list_p = nullptr;
refcount_p = nullptr;
}
+ return *this;
+ }
+
+ inline const ObjIterator<T> operator++(int) {
+ ObjIterator<T> result(*this);
+ ++(*this);
+ return result;
}
};