3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-12 12:41:28 +00:00

Fix Const::const_iterator tag to be bidirectional_iterator_tag

This commit is contained in:
Robert O'Callahan 2025-08-29 04:34:41 +00:00
parent 4657768506
commit 8bae779bb8
2 changed files with 8 additions and 8 deletions

View file

@ -579,11 +579,11 @@ void RTLIL::Const::append(const RTLIL::Const &other) {
} }
RTLIL::State RTLIL::Const::const_iterator::operator*() const { 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]; return (*bv)[idx];
int char_idx = parent.get_str().size() - idx / 8 - 1; int char_idx = parent->get_str().size() - idx / 8 - 1;
bool bit = (parent.get_str()[char_idx] & (1 << (idx % 8))); bool bit = (parent->get_str()[char_idx] & (1 << (idx % 8)));
return bit ? State::S1 : State::S0; return bit ? State::S1 : State::S0;
} }

View file

@ -789,17 +789,17 @@ public:
class const_iterator { class const_iterator {
private: private:
const Const& parent; const Const* parent;
size_t idx; size_t idx;
public: public:
using iterator_category = std::input_iterator_tag; using iterator_category = std::bidirectional_iterator_tag;
using value_type = State; using value_type = State;
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
using pointer = const State*; using pointer = const State*;
using reference = 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; State operator*() const;
@ -810,10 +810,10 @@ public:
const_iterator& operator+=(int i) { idx += i; return *this; } const_iterator& operator+=(int i) { idx += i; return *this; }
const_iterator operator+(int add) { const_iterator operator+(int add) {
return const_iterator(parent, idx + add); return const_iterator(*parent, idx + add);
} }
const_iterator operator-(int sub) { const_iterator operator-(int sub) {
return const_iterator(parent, idx - sub); return const_iterator(*parent, idx - sub);
} }
int operator-(const const_iterator& other) { int operator-(const const_iterator& other) {
return idx - other.idx; return idx - other.idx;