[llvm] [llvm][Object] Add missing const qualifier for value_type in content_iterator (PR #124106)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 12:17:07 PST 2025


================
@@ -38,3 +40,24 @@ TEST(Object, DataRefImplOstream) {
 
   EXPECT_EQ(Expected, s);
 }
+
+struct ProxyContent {
+  unsigned Index = 0;
+  ProxyContent(unsigned Index) : Index(Index) {};
+  void moveNext() { Index++; }
+
+  bool operator==(const ProxyContent &Another) const {
+    return Index == Another.Index;
+  }
+};
+
+TEST(Object, ContentIterator) {
+  using Iter = llvm::object::content_iterator<ProxyContent>;
+  auto Sequence = llvm::make_range(Iter(0u), Iter(10u));
+  auto EvenSequence = llvm::make_filter_range(
+      Sequence, [](auto &&PC) { return PC.Index % 2 == 0; });
+
+  for (auto &&[I, Value] : llvm::enumerate(EvenSequence)) {
----------------
kuhar wrote:

You can use `EXPECT_THAT(EvenSequence, ElementsAre(...))`

https://github.com/llvm/llvm-project/pull/124106


More information about the llvm-commits mailing list