From: Ilya Biryukov Date: Fri, 18 Jan 2019 17:30:49 +0000 (+0000) Subject: [Support] Implement llvm::Registry::iterator via llvm_iterator_facade X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f01b11687725792e986a27ead69dcbcee9b6683;p=llvm [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351566 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/Registry.h b/include/llvm/Support/Registry.h index 02fd5b9354a..395745c6825 100644 --- a/include/llvm/Support/Registry.h +++ b/include/llvm/Support/Registry.h @@ -81,17 +81,17 @@ namespace llvm { /// Iterators for registry entries. /// - class iterator { + class iterator + : public llvm::iterator_facade_base { 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