Skip to content

Commit

Permalink
[Support] Implement llvm::Registry::iterator via llvm_iterator_facade
Browse files Browse the repository at this point in the history
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

llvm-svn: 351566
  • Loading branch information
ilya-biryukov committed Jan 18, 2019
1 parent 826ef59 commit 0cddc39
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/Support/Registry.h
Expand Up @@ -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
Expand Down

0 comments on commit 0cddc39

Please sign in to comment.