From 1c2fb078eb18d7748162540501ded461f4be090e Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Wed, 12 Jun 2024 13:27:22 +0200 Subject: [PATCH] iterator hell --- kernel/rtlil.h | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index e7c064c24..22eb5d755 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -1684,7 +1684,12 @@ public: return !size(); } // AAA - class iterator: public std::iterator> { + class iterator { + typedef std::bidirectional_iterator_tag iterator_category; + typedef std::pair value_type; + typedef ptrdiff_t difference_type; + typedef std::pair* pointer; + typedef std::pair& reference; Cell* parent; int position; public: @@ -1747,7 +1752,12 @@ public: } } // AAA CONST ITERATOR - class const_iterator: public std::iterator> { + class const_iterator { + typedef std::input_iterator_tag iterator_category; + typedef std::pair value_type; + typedef ptrdiff_t difference_type; + typedef std::pair* pointer; + typedef std::pair& reference; Cell* parent; int position; public: @@ -1825,7 +1835,12 @@ public: return !size(); } // AAA - class iterator: public std::iterator> { + class iterator { + typedef std::bidirectional_iterator_tag iterator_category; + typedef std::pair value_type; + typedef ptrdiff_t difference_type; + typedef std::pair* pointer; + typedef std::pair& reference; Cell* parent; int position; public: @@ -1890,7 +1905,12 @@ public: } } // AAA CONST ITERATOR - class const_iterator: public std::iterator> { + class const_iterator { + typedef std::input_iterator_tag iterator_category; + typedef std::pair value_type; + typedef ptrdiff_t difference_type; + typedef std::pair* pointer; + typedef std::pair& reference; Cell* parent; int position; public: @@ -1917,7 +1937,7 @@ public: } else if (parent->type == ID($not)) { return parent->not_.connections()[position]; } else { - log_assert(false && "malformed cell or code broke"); + throw std::out_of_range("FakeConns.const_iterator::operator*() const"); } } }; @@ -1951,7 +1971,7 @@ public: bool has_memid() { return is_legacy() && legacy->has_memid(); } bool is_mem_cell() { return is_legacy() && legacy->is_mem_cell(); } // TODO stub - void set_src_attribute(const std::string &src) { }; + void set_src_attribute(const std::string &src) { (void)src; }; void setPort(const RTLIL::IdString &portname, RTLIL::SigSpec signal); const RTLIL::SigSpec &getPort(const RTLIL::IdString &portname); @@ -1967,7 +1987,7 @@ public: } template void rewrite_sigspecs(T &functor) { - for (auto &it : connections_) + for (std::pair &it : connections_) functor(it.second); } void sort() {