[llvm] 8456e0c - [ADT] Allow std::next to work on BitVector's set_bits_iterator (#80830)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 03:03:24 PST 2024
Author: Jay Foad
Date: 2024-02-13T11:03:20Z
New Revision: 8456e0c290f759807023924481712767a19464c2
URL: https://github.com/llvm/llvm-project/commit/8456e0c290f759807023924481712767a19464c2
DIFF: https://github.com/llvm/llvm-project/commit/8456e0c290f759807023924481712767a19464c2.diff
LOG: [ADT] Allow std::next to work on BitVector's set_bits_iterator (#80830)
Without this I would hit errors with libstdc++-12 like:
/usr/include/c++/12/bits/stl_iterator_base_funcs.h:230:5: note:
candidate template ignored: substitution failure [with _InputIterator =
llvm::const_set_bits_iterator_impl<llvm::BitVector>]: argument may not
have 'void' type
next(_InputIterator __x, typename
^
Added:
Modified:
llvm/include/llvm/ADT/BitVector.h
llvm/unittests/ADT/BitVectorTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index e0de1afcc94182..0eaa77b6dd81ce 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -42,7 +42,7 @@ template <typename BitVectorT> class const_set_bits_iterator_impl {
public:
using iterator_category = std::forward_iterator_tag;
- using
diff erence_type = void;
+ using
diff erence_type = std::ptr
diff _t;
using value_type = int;
using pointer = value_type*;
using reference = value_type&;
diff --git a/llvm/unittests/ADT/BitVectorTest.cpp b/llvm/unittests/ADT/BitVectorTest.cpp
index e00e11e4655aa0..6a4780c143e548 100644
--- a/llvm/unittests/ADT/BitVectorTest.cpp
+++ b/llvm/unittests/ADT/BitVectorTest.cpp
@@ -1143,6 +1143,9 @@ TYPED_TEST(BitVectorTest, EmptyVectorGetData) {
}
TYPED_TEST(BitVectorTest, Iterators) {
+ TypeParam Singleton(1, true);
+ EXPECT_EQ(std::next(Singleton.set_bits_begin()), Singleton.set_bits_end());
+
TypeParam Filled(10, true);
EXPECT_NE(Filled.set_bits_begin(), Filled.set_bits_end());
unsigned Counter = 0;
More information about the llvm-commits
mailing list