diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2019-10-03 11:24:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-03 11:24:15 -0700 |
commit | 24ad028cdd3f72b5c9123e9718c63e7613e0a841 (patch) | |
tree | 2d93e1064700a68169ed2b5aa89f3ca869a8831e /src | |
parent | 51181eb3382ae9c94f90a39103e33ec6e9063dee (diff) |
Add missing type definitions to CDHashMap iterator (#3330)
Our `CDMapBlack` test failed to compile with newer versions of libstdc++
because they require the `value_type` to be defined for the iterator
(accessed via `std::iterator_traits`). Due to the implementation of
`std::iterator_traits`, we also need to define `iterator_category`,
`difference_type`, `pointer`, and `reference`.
Diffstat (limited to 'src')
-rw-r--r-- | src/context/cdhashmap.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/context/cdhashmap.h b/src/context/cdhashmap.h index 0a1f3387c..05d68ead5 100644 --- a/src/context/cdhashmap.h +++ b/src/context/cdhashmap.h @@ -82,6 +82,7 @@ #ifndef CVC4__CONTEXT__CDHASHMAP_H #define CVC4__CONTEXT__CDHASHMAP_H +#include <cstddef> #include <functional> #include <iterator> #include <unordered_map> @@ -394,7 +395,12 @@ public: class iterator { const Element* d_it; - public: + public: + using iterator_category = std::input_iterator_tag; + using value_type = typename CDOhash_map<Key, Data, HashFcn>::value_type; + using difference_type = ptrdiff_t; + using pointer = typename CDOhash_map<Key, Data, HashFcn>::value_type*; + using reference = typename CDOhash_map<Key, Data, HashFcn>::value_type&; iterator(const Element* p) : d_it(p) {} iterator(const iterator& i) : d_it(i.d_it) {} @@ -403,18 +409,15 @@ public: iterator() : d_it(nullptr) {} // (Dis)equality - bool operator==(const iterator& i) const { - return d_it == i.d_it; - } - bool operator!=(const iterator& i) const { - return d_it != i.d_it; - } + bool operator==(const iterator& i) const { return d_it == i.d_it; } + bool operator!=(const iterator& i) const { return d_it != i.d_it; } // Dereference operators. const value_type& operator*() const { return d_it->getValue(); } // Prefix increment - iterator& operator++() { + iterator& operator++() + { d_it = d_it->next(); return *this; } |