Fix postincrement in truncating and counting iterators

This commit is contained in:
Victor Zverovich
2018-06-07 20:20:36 +02:00
parent 4bc26f0a7b
commit 1b8a7f8fa0
3 changed files with 28 additions and 13 deletions
+10 -2
View File
@@ -840,7 +840,11 @@ class counting_iterator {
return *this;
}
counting_iterator operator++(int) { return ++*this; }
counting_iterator operator++(int) {
auto it = *this;
++*this;
return it;
}
T &operator*() const { return blackhole_; }
};
@@ -877,7 +881,11 @@ class truncating_iterator {
return *this;
}
truncating_iterator operator++(int) { return ++*this; }
truncating_iterator operator++(int) {
auto it = *this;
++*this;
return it;
}
reference operator*() const { return count_ < limit_ ? *out_ : blackhole_; }
};