summaryrefslogtreecommitdiff
path: root/src/context
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2019-10-03 11:24:15 -0700
committerGitHub <noreply@github.com>2019-10-03 11:24:15 -0700
commit24ad028cdd3f72b5c9123e9718c63e7613e0a841 (patch)
tree2d93e1064700a68169ed2b5aa89f3ca869a8831e /src/context
parent51181eb3382ae9c94f90a39103e33ec6e9063dee (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/context')
-rw-r--r--src/context/cdhashmap.h19
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;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback