Skip to content

Commit a1ddfb5

Browse files
author
Krzysztof Parzyszek
authored
Remove uses of std::iterator, NFC (#12461)
std::iterator is deprecated in C++17. It only defined some member types, and the new recommended solution is to define these members directly.
1 parent 247c54b commit a1ddfb5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

include/tvm/support/span.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,17 @@ template <class T, class W>
4242
class Span {
4343
public:
4444
using value_type = W;
45-
using const_W = typename ::std::add_const<W>::type;
45+
using const_W = typename std::add_const<W>::type;
4646

4747
template <class W1>
48-
class iterator_base : public std::iterator<std::input_iterator_tag, W> {
48+
class iterator_base {
4949
public:
50+
using iterator_category = std::input_iterator_tag;
51+
using value_type = W;
52+
using difference_type = std::ptrdiff_t;
53+
using pointer = const W*;
54+
using reference = const W&;
55+
5056
inline iterator_base(T* ptr, T* end) : ptr_{ptr}, end_{end} { CHECK_GE(end, ptr); }
5157

5258
inline W1 operator*() { return W1(*ptr_); }
@@ -62,7 +68,7 @@ class Span {
6268

6369
inline bool operator!=(iterator_base<W1> other) { return !(*this == other); }
6470

65-
template <class X = W1, typename = ::std::enable_if_t<!::std::is_const<X>::value> >
71+
template <class X = W1, typename = std::enable_if_t<!std::is_const<X>::value> >
6672
inline operator iterator_base<const_W>() const {
6773
return iterator_base<const_W>(ptr_, end_);
6874
}

0 commit comments

Comments
 (0)