Skip to content

Commit 1db3f38

Browse files
authored
Remove std::iterator inheritance, which is deprecated in C++17. (#7597)
Building on Debian 13, with g++ 14.2.0, one of the warnings (which were not treated as errors) was: .../reader.h:80:30: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations]
1 parent 7a62a21 commit 1db3f38

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

clients/drcachesim/common/directory_iterator.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ namespace drmemtrace {
5757
// Iterates over files: skips sub-directories.
5858
// Returns the basenames of the files (i.e., not absolute paths).
5959
// This class is not thread-safe.
60-
class directory_iterator_t : public std::iterator<std::input_iterator_tag, std::string> {
60+
class directory_iterator_t {
6161
public:
62+
using iterator_category = std::input_iterator_tag;
63+
using value_type = std::string;
64+
using difference_type = std::ptrdiff_t;
65+
using pointer = value_type *;
66+
using reference = value_type &;
6267
directory_iterator_t()
6368
{
6469
}

clients/drcachesim/reader/reader.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,13 @@ namespace drmemtrace {
7777
* also provides more information about the trace using the
7878
* #dynamorio::drmemtrace::memtrace_stream_t API.
7979
*/
80-
class reader_t : public std::iterator<std::input_iterator_tag, memref_t>,
81-
public memtrace_stream_t {
80+
class reader_t : public memtrace_stream_t {
8281
public:
82+
using iterator_category = std::input_iterator_tag;
83+
using value_type = memref_t;
84+
using difference_type = std::ptrdiff_t;
85+
using pointer = value_type *;
86+
using reference = value_type &;
8387
reader_t()
8488
{
8589
cur_ref_ = {};

clients/drcachesim/reader/record_file_reader.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ namespace drmemtrace {
111111
* record_reader_t is expected to provide the exact stream of
112112
* #dynamorio::drmemtrace::trace_entry_t as stored on disk.
113113
*/
114-
class record_reader_t : public std::iterator<std::input_iterator_tag, trace_entry_t>,
115-
public memtrace_stream_t {
114+
class record_reader_t : public memtrace_stream_t {
116115
public:
116+
using iterator_category = std::input_iterator_tag;
117+
using value_type = trace_entry_t;
118+
using difference_type = std::ptrdiff_t;
119+
using pointer = value_type *;
120+
using reference = value_type &;
117121
record_reader_t(int verbosity, const char *prefix)
118122
: verbosity_(verbosity)
119123
, output_prefix_(prefix)

clients/drcachesim/tracer/instru.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ class reg_id_set_t {
7373
memset(present_, 0, sizeof(present_));
7474
}
7575

76-
class reg_id_set_iterator_t
77-
: public std::iterator<std::input_iterator_tag, reg_id_t> {
76+
class reg_id_set_iterator_t {
7877
public:
78+
using iterator_category = std::input_iterator_tag;
79+
using value_type = reg_id_t;
80+
using difference_type = std::ptrdiff_t;
81+
using pointer = value_type *;
82+
using reference = value_type &;
7983
reg_id_set_iterator_t(reg_id_set_t *set)
8084
: set_(set)
8185
, index_(-1)

0 commit comments

Comments
 (0)