[PATCH] D117116: [llvm][ADT] Enable range-based for loops for `BitVector`

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 12 13:56:09 PST 2022


dexonsmith added a reviewer: dblaikie.
dexonsmith added a comment.

Given that `BitVector::reference` already exists for `operator[]`, might be nice to add `iterator` as well.



================
Comment at: llvm/include/llvm/ADT/BitVector.h:33
+/// Iterators get invalidated when resize / reserve is called.
+template <typename BitVectorT> class const_all_bits_iterator_impl {
+  using size_type = typename BitVectorT::size_type;
----------------
It'd probably be easiest to use `iterator_facade_base` (from `ADT/Iterator.h` IIRC?). Value type should be `const bool` here.


================
Comment at: llvm/include/llvm/ADT/BitVector.h:163
 
+  using const_all_bits_iterator = const_all_bits_iterator_impl<BitVector>;
+
----------------
Maybe this should just be `const_iterator`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117116/new/

https://reviews.llvm.org/D117116



More information about the llvm-commits mailing list