[PATCH] D56854: [Support] Implement llvm::Registry::iterator via llvm_iterator_facade
Ilya Biryukov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 17 07:31:30 PST 2019
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added a subscriber: kristina.
Among other things, this allows using STL algorithms like 'find_if' over
llvm::Registry.
Repository:
rL LLVM
https://reviews.llvm.org/D56854
Files:
include/llvm/Support/Registry.h
Index: include/llvm/Support/Registry.h
===================================================================
--- include/llvm/Support/Registry.h
+++ include/llvm/Support/Registry.h
@@ -81,17 +81,17 @@
/// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56854.182288.patch
Type: text/x-patch
Size: 962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190117/04d1617e/attachment.bin>
More information about the llvm-commits
mailing list