[llvm] r351566 - [Support] Implement llvm::Registry::iterator via llvm_iterator_facade

Ilya Biryukov via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 18 09:30:49 PST 2019


Author: ibiryukov
Date: Fri Jan 18 09:30:49 2019
New Revision: 351566

URL: http://llvm.org/viewvc/llvm-project?rev=351566&view=rev
Log:
[Support] Implement llvm::Registry::iterator via llvm_iterator_facade

Summary:
Among other things, this allows using STL algorithms like 'find_if' over
llvm::Registry.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: kristina, llvm-commits

Differential Revision: https://reviews.llvm.org/D56854

Modified:
    llvm/trunk/include/llvm/Support/Registry.h

Modified: llvm/trunk/include/llvm/Support/Registry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Registry.h?rev=351566&r1=351565&r2=351566&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Registry.h (original)
+++ llvm/trunk/include/llvm/Support/Registry.h Fri Jan 18 09:30:49 2019
@@ -81,17 +81,17 @@ namespace llvm {
 
     /// Iterators for registry entries.
     ///
-    class iterator {
+    class iterator
+        : public llvm::iterator_facade_base<iterator, std::forward_iterator_tag,
+                                            const entry> {
       const node *Cur;
 
     public:
       explicit iterator(const node *N) : Cur(N) {}
 
       bool operator==(const iterator &That) const { return Cur == That.Cur; }
-      bool operator!=(const iterator &That) const { return Cur != That.Cur; }
       iterator &operator++() { Cur = Cur->Next; return *this; }
       const entry &operator*() const { return Cur->Val; }
-      const entry *operator->() const { return &Cur->Val; }
     };
 
     // begin is not defined here in order to avoid usage of an undefined static




More information about the llvm-commits mailing list