From: Andres Noetzli Date: Thu, 3 Oct 2019 18:24:15 +0000 (-0700) Subject: Add missing type definitions to CDHashMap iterator (#3330) X-Git-Tag: cvc5-1.0.0~3918 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=24ad028cdd3f72b5c9123e9718c63e7613e0a841;p=cvc5.git 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`. --- 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 #include #include #include @@ -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::value_type; + using difference_type = ptrdiff_t; + using pointer = typename CDOhash_map::value_type*; + using reference = typename CDOhash_map::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; }