From: Clifford Wolf Date: Sun, 27 Jul 2014 08:41:06 +0000 (+0200) Subject: Added conversion from ObjRange to std::vector and std::set X-Git-Tag: yosys-0.4~401 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d088854b47f5f77c6a62be2ba4b895164938d7a2;p=yosys.git Added conversion from ObjRange to std::vector and std::set --- diff --git a/kernel/rtlil.h b/kernel/rtlil.h index be2822706..2fbfe8049 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -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 begin() { return RTLIL::ObjIterator(list_p, refcount_p); } RTLIL::ObjIterator end() { return RTLIL::ObjIterator(); } + + operator std::set() const { + std::set result; + for (auto &it : *list_p) + result.insert(it.second); + return result; + } + + operator std::vector() const { + std::vector result; + result.reserve(list_p->size()); + for (auto &it : *list_p) + result.push_back(it.second); + return result; + } }; };