From 8bae779bb85df2175a47b148dbb2f10ce7d6f03a Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 29 Aug 2025 04:34:41 +0000 Subject: [PATCH] Fix Const::const_iterator tag to be bidirectional_iterator_tag --- kernel/rtlil.cc | 6 +++--- kernel/rtlil.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 0250346d1..fc007c3bf 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -579,11 +579,11 @@ void RTLIL::Const::append(const RTLIL::Const &other) { } RTLIL::State RTLIL::Const::const_iterator::operator*() const { - if (auto bv = parent.get_if_bits()) + if (auto bv = parent->get_if_bits()) return (*bv)[idx]; - int char_idx = parent.get_str().size() - idx / 8 - 1; - bool bit = (parent.get_str()[char_idx] & (1 << (idx % 8))); + int char_idx = parent->get_str().size() - idx / 8 - 1; + bool bit = (parent->get_str()[char_idx] & (1 << (idx % 8))); return bit ? State::S1 : State::S0; } diff --git a/kernel/rtlil.h b/kernel/rtlil.h index e36558359..f2279645e 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -789,17 +789,17 @@ public: class const_iterator { private: - const Const& parent; + const Const* parent; size_t idx; public: - using iterator_category = std::input_iterator_tag; + using iterator_category = std::bidirectional_iterator_tag; using value_type = State; using difference_type = std::ptrdiff_t; using pointer = const State*; using reference = const State&; - const_iterator(const Const& c, size_t i) : parent(c), idx(i) {} + const_iterator(const Const& c, size_t i) : parent(&c), idx(i) {} State operator*() const; @@ -810,10 +810,10 @@ public: const_iterator& operator+=(int i) { idx += i; return *this; } const_iterator operator+(int add) { - return const_iterator(parent, idx + add); + return const_iterator(*parent, idx + add); } const_iterator operator-(int sub) { - return const_iterator(parent, idx - sub); + return const_iterator(*parent, idx - sub); } int operator-(const const_iterator& other) { return idx - other.idx;