Added conversion from ObjRange to std::vector and std::set
authorClifford Wolf <clifford@clifford.at>
Sun, 27 Jul 2014 08:41:06 +0000 (10:41 +0200)
committerClifford Wolf <clifford@clifford.at>
Sun, 27 Jul 2014 09:18:30 +0000 (11:18 +0200)
kernel/rtlil.h

index be2822706a0bfd670372c8028075ec0b539696dc..2fbfe8049da19c4a55ff3f9a99274ae5994658b9 100644 (file)
@@ -268,6 +268,21 @@ namespace RTLIL
                ObjRange(decltype(list_p) list_p, int *refcount_p) : list_p(list_p), refcount_p(refcount_p) { }
                RTLIL::ObjIterator<T> begin() { return RTLIL::ObjIterator<T>(list_p, refcount_p); }
                RTLIL::ObjIterator<T> end() { return RTLIL::ObjIterator<T>(); }
+
+               operator std::set<T>() const {
+                       std::set<T> result;
+                       for (auto &it : *list_p)
+                               result.insert(it.second);
+                       return result;
+               }
+
+               operator std::vector<T>() const {
+                       std::vector<T> result;
+                       result.reserve(list_p->size());
+                       for (auto &it : *list_p)
+                               result.push_back(it.second);
+                       return result;
+               }
        };
 };