Skip to content

Commit 29faa09

Browse files
committed
Fix constness on dereferencing a filter_iteratort
Dereferencing a `filter_iteratort` from filtering a const collection with `ranget` would previously introduce a compile error, due to a `const` to non-const conversion. This commit fixes this, by using the same return type as the iterator which it wraps around.
1 parent dcbda65 commit 29faa09

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/util/range.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class filter_iteratort
113113
public:
114114
using difference_type = typename iteratort::difference_type;
115115
using value_type = typename iteratort::value_type;
116-
using pointer = const value_type *;
117-
using reference = const value_type &;
116+
using pointer = typename iteratort::pointer;
117+
using reference = typename iteratort::reference;
118118
using iterator_category = std::forward_iterator_tag;
119119

120120
bool operator==(const filter_iteratort &other) const
@@ -143,12 +143,12 @@ class filter_iteratort
143143
return tmp;
144144
}
145145

146-
value_type &operator*()
146+
reference operator*()
147147
{
148148
return *underlying;
149149
}
150150

151-
value_type *operator->()
151+
pointer operator->()
152152
{
153153
return &(*underlying);
154154
}

0 commit comments

Comments
 (0)