Skip to content

Commit 278fb51

Browse files
Merge pull request #8088 from thomasspriggs/tas/no_std_iterator
Remove usages of the deprecated `std::iterator`
2 parents 10d922c + 05020d2 commit 278fb51

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/util/cmdline.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,15 @@ class cmdlinet
105105
{
106106
explicit option_namest(const cmdlinet &command_line);
107107
struct option_names_iteratort
108-
: public std::iterator<std::forward_iterator_tag, std::string>
109108
{
109+
// These types are defined such that the class is compatible with being
110+
// treated as an STL iterator. For this to work, they must not be renamed.
111+
using iterator_category = std::forward_iterator_tag;
112+
using value_type = std::string;
113+
using difference_type = std::ptrdiff_t;
114+
using pointer = const std::string *;
115+
using reference = const std::string &;
116+
110117
option_names_iteratort() = default;
111118
explicit option_names_iteratort(
112119
const cmdlinet *command_line,

src/util/dense_integer_map.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,21 @@ class dense_integer_mapt
116116
// operator++ that skips unset values.
117117
template <class UnderlyingIterator, class UnderlyingValue>
118118
class iterator_templatet
119-
: public std::iterator<std::forward_iterator_tag, UnderlyingValue>
120119
{
121-
// Type of the std::iterator support class we inherit
122-
typedef std::iterator<std::forward_iterator_tag, UnderlyingValue>
123-
base_typet;
124120
// Type of this template instantiation
125121
typedef iterator_templatet<UnderlyingIterator, UnderlyingValue> self_typet;
126122
// Type of our containing \ref dense_integer_mapt
127123
typedef dense_integer_mapt<K, V, KeyToDenseInteger> map_typet;
128124

129125
public:
126+
// These types are defined such that the class is compatible with being
127+
// treated as an STL iterator. For this to work, they must not be renamed.
128+
using iterator_category = std::forward_iterator_tag;
129+
using value_type = UnderlyingValue;
130+
using difference_type = std::ptrdiff_t;
131+
using pointer = UnderlyingValue *;
132+
using reference = UnderlyingValue &;
133+
130134
iterator_templatet(UnderlyingIterator it, const map_typet &underlying_map)
131135
: underlying_iterator(it), underlying_map(underlying_map)
132136
{
@@ -153,11 +157,11 @@ class dense_integer_mapt
153157
underlying_iterator = advance(underlying_iterator);
154158
return *this;
155159
}
156-
typename base_typet::reference operator*() const
160+
reference operator*() const
157161
{
158162
return *underlying_iterator;
159163
}
160-
typename base_typet::pointer operator->() const
164+
pointer operator->() const
161165
{
162166
return &*underlying_iterator;
163167
}

0 commit comments

Comments
 (0)