mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #4062 from povik/iterator-c++17
Remove deprecated `std::iterator`, fix iterator types
This commit is contained in:
commit
fe686e725f
|
@ -371,7 +371,7 @@ class dict
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class const_iterator : public std::iterator<std::forward_iterator_tag, std::pair<K, T>>
|
class const_iterator
|
||||||
{
|
{
|
||||||
friend class dict;
|
friend class dict;
|
||||||
protected:
|
protected:
|
||||||
|
@ -379,6 +379,11 @@ public:
|
||||||
int index;
|
int index;
|
||||||
const_iterator(const dict *ptr, int index) : ptr(ptr), index(index) { }
|
const_iterator(const dict *ptr, int index) : ptr(ptr), index(index) { }
|
||||||
public:
|
public:
|
||||||
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
typedef std::pair<K, T> value_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef std::pair<K, T>* pointer;
|
||||||
|
typedef std::pair<K, T>& reference;
|
||||||
const_iterator() { }
|
const_iterator() { }
|
||||||
const_iterator operator++() { index--; return *this; }
|
const_iterator operator++() { index--; return *this; }
|
||||||
const_iterator operator+=(int amt) { index -= amt; return *this; }
|
const_iterator operator+=(int amt) { index -= amt; return *this; }
|
||||||
|
@ -389,7 +394,7 @@ public:
|
||||||
const std::pair<K, T> *operator->() const { return &ptr->entries[index].udata; }
|
const std::pair<K, T> *operator->() const { return &ptr->entries[index].udata; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class iterator : public std::iterator<std::forward_iterator_tag, std::pair<K, T>>
|
class iterator
|
||||||
{
|
{
|
||||||
friend class dict;
|
friend class dict;
|
||||||
protected:
|
protected:
|
||||||
|
@ -397,6 +402,11 @@ public:
|
||||||
int index;
|
int index;
|
||||||
iterator(dict *ptr, int index) : ptr(ptr), index(index) { }
|
iterator(dict *ptr, int index) : ptr(ptr), index(index) { }
|
||||||
public:
|
public:
|
||||||
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
typedef std::pair<K, T> value_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef std::pair<K, T>* pointer;
|
||||||
|
typedef std::pair<K, T>& reference;
|
||||||
iterator() { }
|
iterator() { }
|
||||||
iterator operator++() { index--; return *this; }
|
iterator operator++() { index--; return *this; }
|
||||||
iterator operator+=(int amt) { index -= amt; return *this; }
|
iterator operator+=(int amt) { index -= amt; return *this; }
|
||||||
|
@ -800,7 +810,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class const_iterator : public std::iterator<std::forward_iterator_tag, K>
|
class const_iterator
|
||||||
{
|
{
|
||||||
friend class pool;
|
friend class pool;
|
||||||
protected:
|
protected:
|
||||||
|
@ -808,6 +818,11 @@ public:
|
||||||
int index;
|
int index;
|
||||||
const_iterator(const pool *ptr, int index) : ptr(ptr), index(index) { }
|
const_iterator(const pool *ptr, int index) : ptr(ptr), index(index) { }
|
||||||
public:
|
public:
|
||||||
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
typedef K value_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef K* pointer;
|
||||||
|
typedef K& reference;
|
||||||
const_iterator() { }
|
const_iterator() { }
|
||||||
const_iterator operator++() { index--; return *this; }
|
const_iterator operator++() { index--; return *this; }
|
||||||
bool operator==(const const_iterator &other) const { return index == other.index; }
|
bool operator==(const const_iterator &other) const { return index == other.index; }
|
||||||
|
@ -816,7 +831,7 @@ public:
|
||||||
const K *operator->() const { return &ptr->entries[index].udata; }
|
const K *operator->() const { return &ptr->entries[index].udata; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class iterator : public std::iterator<std::forward_iterator_tag, K>
|
class iterator
|
||||||
{
|
{
|
||||||
friend class pool;
|
friend class pool;
|
||||||
protected:
|
protected:
|
||||||
|
@ -824,6 +839,11 @@ public:
|
||||||
int index;
|
int index;
|
||||||
iterator(pool *ptr, int index) : ptr(ptr), index(index) { }
|
iterator(pool *ptr, int index) : ptr(ptr), index(index) { }
|
||||||
public:
|
public:
|
||||||
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
typedef K value_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef K* pointer;
|
||||||
|
typedef K& reference;
|
||||||
iterator() { }
|
iterator() { }
|
||||||
iterator operator++() { index--; return *this; }
|
iterator operator++() { index--; return *this; }
|
||||||
bool operator==(const iterator &other) const { return index == other.index; }
|
bool operator==(const iterator &other) const { return index == other.index; }
|
||||||
|
@ -1021,7 +1041,7 @@ class idict
|
||||||
pool<K, OPS> database;
|
pool<K, OPS> database;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class const_iterator : public std::iterator<std::forward_iterator_tag, K>
|
class const_iterator
|
||||||
{
|
{
|
||||||
friend class idict;
|
friend class idict;
|
||||||
protected:
|
protected:
|
||||||
|
@ -1029,6 +1049,11 @@ public:
|
||||||
int index;
|
int index;
|
||||||
const_iterator(const idict &container, int index) : container(container), index(index) { }
|
const_iterator(const idict &container, int index) : container(container), index(index) { }
|
||||||
public:
|
public:
|
||||||
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
typedef K value_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef K* pointer;
|
||||||
|
typedef K& reference;
|
||||||
const_iterator() { }
|
const_iterator() { }
|
||||||
const_iterator operator++() { index++; return *this; }
|
const_iterator operator++() { index++; return *this; }
|
||||||
bool operator==(const const_iterator &other) const { return index == other.index; }
|
bool operator==(const const_iterator &other) const { return index == other.index; }
|
||||||
|
|
|
@ -803,8 +803,14 @@ struct RTLIL::SigBit
|
||||||
unsigned int hash() const;
|
unsigned int hash() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RTLIL::SigSpecIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
|
struct RTLIL::SigSpecIterator
|
||||||
{
|
{
|
||||||
|
typedef std::input_iterator_tag iterator_category;
|
||||||
|
typedef RTLIL::SigBit value_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef RTLIL::SigBit* pointer;
|
||||||
|
typedef RTLIL::SigBit& reference;
|
||||||
|
|
||||||
RTLIL::SigSpec *sig_p;
|
RTLIL::SigSpec *sig_p;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
@ -814,8 +820,14 @@ struct RTLIL::SigSpecIterator : public std::iterator<std::input_iterator_tag, RT
|
||||||
inline void operator++() { index++; }
|
inline void operator++() { index++; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RTLIL::SigSpecConstIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
|
struct RTLIL::SigSpecConstIterator
|
||||||
{
|
{
|
||||||
|
typedef std::input_iterator_tag iterator_category;
|
||||||
|
typedef RTLIL::SigBit value_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef RTLIL::SigBit* pointer;
|
||||||
|
typedef RTLIL::SigBit& reference;
|
||||||
|
|
||||||
const RTLIL::SigSpec *sig_p;
|
const RTLIL::SigSpec *sig_p;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue