Skip to content

Commit a5b0488

Browse files
authored
[C++17] Merge upsteam change for Don't use std::iterator in PATH.h (#5483)
Merge upstream change llvm/llvm-project@91c8daf In converting this over to iterator_facade_base, some member operators and methods are no longer needed since iterator_facade implements them in the base class using CRTP. This is part of enable C++17.
1 parent 212a2bf commit a5b0488

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

include/llvm/Support/Path.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "llvm/ADT/SmallString.h"
2020
#include "llvm/ADT/Twine.h"
21+
#include "llvm/ADT/iterator.h"
2122
#include "llvm/Support/DataTypes.h"
2223
#include <iterator>
2324

@@ -48,7 +49,8 @@ namespace path {
4849
/// C:\foo\bar => C:,/,foo,bar
4950
/// @endcode
5051
class const_iterator
51-
: public std::iterator<std::input_iterator_tag, const StringRef> {
52+
: public iterator_facade_base<const_iterator, std::input_iterator_tag,
53+
const StringRef> {
5254
StringRef Path; ///< The entire path.
5355
StringRef Component; ///< The current component. Not necessarily in Path.
5456
size_t Position; ///< The iterators current position within Path.
@@ -59,11 +61,9 @@ class const_iterator
5961

6062
public:
6163
reference operator*() const { return Component; }
62-
pointer operator->() const { return &Component; }
6364
const_iterator &operator++(); // preincrement
6465
const_iterator &operator++(int); // postincrement
6566
bool operator==(const const_iterator &RHS) const;
66-
bool operator!=(const const_iterator &RHS) const { return !(*this == RHS); }
6767

6868
/// @brief Difference in bytes between this and RHS.
6969
ptrdiff_t operator-(const const_iterator &RHS) const;
@@ -75,7 +75,8 @@ class const_iterator
7575
/// \a path in reverse order. The traversal order is exactly reversed from that
7676
/// of \a const_iterator
7777
class reverse_iterator
78-
: public std::iterator<std::input_iterator_tag, const StringRef> {
78+
: public iterator_facade_base<reverse_iterator, std::input_iterator_tag,
79+
const StringRef> {
7980
StringRef Path; ///< The entire path.
8081
StringRef Component; ///< The current component. Not necessarily in Path.
8182
size_t Position; ///< The iterators current position within Path.
@@ -85,11 +86,9 @@ class reverse_iterator
8586

8687
public:
8788
reference operator*() const { return Component; }
88-
pointer operator->() const { return &Component; }
8989
reverse_iterator &operator++(); // preincrement
9090
reverse_iterator &operator++(int); // postincrement
9191
bool operator==(const reverse_iterator &RHS) const;
92-
bool operator!=(const reverse_iterator &RHS) const { return !(*this == RHS); }
9392
};
9493

9594
/// @brief Get begin iterator over \a path.

0 commit comments

Comments
 (0)