aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/iterator/enumerate.h
diff options
context:
space:
mode:
authorpavook <pavook@yandex-team.com>2024-07-31 12:03:17 +0300
committerpavook <pavook@yandex-team.com>2024-07-31 12:17:03 +0300
commitc4fb2cdf41179910a4e9632de119ab3c94b741bc (patch)
treebed136492bcce6a53acb13c6145f0afd06843677 /library/cpp/iterator/enumerate.h
parent27b7ec6ec161019a7cb8f731166e892c60e863e1 (diff)
downloadydb-c4fb2cdf41179910a4e9632de119ab3c94b741bc.tar.gz
Fix TEnumerator::TIterator
082782faf0e6e05d3aa1c56e096d33ea69282f57
Diffstat (limited to 'library/cpp/iterator/enumerate.h')
-rw-r--r--library/cpp/iterator/enumerate.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/library/cpp/iterator/enumerate.h b/library/cpp/iterator/enumerate.h
index 2c83fb41bf..6ebc12a0e7 100644
--- a/library/cpp/iterator/enumerate.h
+++ b/library/cpp/iterator/enumerate.h
@@ -27,23 +27,30 @@ namespace NPrivate {
struct TIterator {
using difference_type = std::ptrdiff_t;
using value_type = TValue;
- using pointer = TValue*;
- using reference = TValue&;
+ using pointer = void;
+ using reference = value_type;
using iterator_category = std::input_iterator_tag;
- TValue operator*() {
+ reference operator*() const {
return {Index_, *Iterator_};
}
- TValue operator*() const {
- return {Index_, *Iterator_};
- }
- void operator++() {
+
+ TIterator& operator++() {
++Index_;
++Iterator_;
+ return *this;
+ }
+
+ TIterator operator++(int) {
+ TIterator result = *this;
+ ++(*this);
+ return result;
}
+
bool operator!=(const TSentinel& other) const {
return Iterator_ != other.Iterator_;
}
+
bool operator==(const TSentinel& other) const {
return Iterator_ == other.Iterator_;
}
@@ -51,6 +58,7 @@ namespace NPrivate {
std::size_t Index_;
TIteratorState Iterator_;
};
+
public:
using iterator = TIterator;
using const_iterator = TIterator;