[libcxx-commits] [libcxx] [libcxx][test] Do not assume array::iterator is a pointer (PR #100603)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 27 12:13:40 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 3eaf9f7237b088e9382739808d4f723b2c11dd8c 885742250b2cb81a281e1fa36f6b5dab657dd395 --extensions h,cpp -- libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last.pass.cpp libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if.pass.cpp libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if_not.pass.cpp libcxx/test/support/test_iterators.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/support/test_iterators.h b/libcxx/test/support/test_iterators.h
index ef27ab4f6b..44bd4a5975 100644
--- a/libcxx/test/support/test_iterators.h
+++ b/libcxx/test/support/test_iterators.h
@@ -364,70 +364,67 @@ public:
 
   template <class U, class = typename std::enable_if<std::is_default_constructible<U>::value>::type>
   constexpr contiguous_iterator(contiguous_iterator<U>&& u) : it_(u.it_) {
-    u.it_ = U(); }
+    u.it_ = U();
+  }
 
-    constexpr reference operator*() const { return *it_; }
-    constexpr pointer operator->() const { return it_; }
-    constexpr reference operator[](difference_type n) const { return it_[n]; }
+  constexpr reference operator*() const { return *it_; }
+  constexpr pointer operator->() const { return it_; }
+  constexpr reference operator[](difference_type n) const { return it_[n]; }
 
-    constexpr contiguous_iterator& operator++() {
-      ++it_;
-      return *this;
-    }
-    constexpr contiguous_iterator& operator--() {
-      --it_;
-      return *this;
-    }
-    constexpr contiguous_iterator operator++(int) { return contiguous_iterator(it_++); }
-    constexpr contiguous_iterator operator--(int) { return contiguous_iterator(it_--); }
+  constexpr contiguous_iterator& operator++() {
+    ++it_;
+    return *this;
+  }
+  constexpr contiguous_iterator& operator--() {
+    --it_;
+    return *this;
+  }
+  constexpr contiguous_iterator operator++(int) { return contiguous_iterator(it_++); }
+  constexpr contiguous_iterator operator--(int) { return contiguous_iterator(it_--); }
 
-    constexpr contiguous_iterator& operator+=(difference_type n) {
-      it_ += n;
-      return *this;
-    }
-    constexpr contiguous_iterator& operator-=(difference_type n) {
-      it_ -= n;
-      return *this;
-    }
-    friend constexpr contiguous_iterator operator+(contiguous_iterator x, difference_type n) {
-      x += n;
-      return x;
-    }
-    friend constexpr contiguous_iterator operator+(difference_type n, contiguous_iterator x) {
-      x += n;
-      return x;
-    }
-    friend constexpr contiguous_iterator operator-(contiguous_iterator x, difference_type n) {
-      x -= n;
-      return x;
-    }
-    friend constexpr difference_type operator-(contiguous_iterator x, contiguous_iterator y) { return x.it_ - y.it_; }
+  constexpr contiguous_iterator& operator+=(difference_type n) {
+    it_ += n;
+    return *this;
+  }
+  constexpr contiguous_iterator& operator-=(difference_type n) {
+    it_ -= n;
+    return *this;
+  }
+  friend constexpr contiguous_iterator operator+(contiguous_iterator x, difference_type n) {
+    x += n;
+    return x;
+  }
+  friend constexpr contiguous_iterator operator+(difference_type n, contiguous_iterator x) {
+    x += n;
+    return x;
+  }
+  friend constexpr contiguous_iterator operator-(contiguous_iterator x, difference_type n) {
+    x -= n;
+    return x;
+  }
+  friend constexpr difference_type operator-(contiguous_iterator x, contiguous_iterator y) { return x.it_ - y.it_; }
 
-    friend constexpr bool operator==(const contiguous_iterator& x, const contiguous_iterator& y) {
-      return x.it_ == y.it_;
-    }
-    friend constexpr bool operator!=(const contiguous_iterator& x, const contiguous_iterator& y) {
-      return x.it_ != y.it_;
-    }
-    friend constexpr bool operator<(const contiguous_iterator& x, const contiguous_iterator& y) {
-      return x.it_ < y.it_;
-    }
-    friend constexpr bool operator<=(const contiguous_iterator& x, const contiguous_iterator& y) {
-      return x.it_ <= y.it_;
-    }
-    friend constexpr bool operator>(const contiguous_iterator& x, const contiguous_iterator& y) {
-      return x.it_ > y.it_;
-    }
-    friend constexpr bool operator>=(const contiguous_iterator& x, const contiguous_iterator& y) {
-      return x.it_ >= y.it_;
-    }
+  friend constexpr bool operator==(const contiguous_iterator& x, const contiguous_iterator& y) {
+    return x.it_ == y.it_;
+  }
+  friend constexpr bool operator!=(const contiguous_iterator& x, const contiguous_iterator& y) {
+    return x.it_ != y.it_;
+  }
+  friend constexpr bool operator<(const contiguous_iterator& x, const contiguous_iterator& y) { return x.it_ < y.it_; }
+  friend constexpr bool operator<=(const contiguous_iterator& x, const contiguous_iterator& y) {
+    return x.it_ <= y.it_;
+  }
+  friend constexpr bool operator>(const contiguous_iterator& x, const contiguous_iterator& y) { return x.it_ > y.it_; }
+  friend constexpr bool operator>=(const contiguous_iterator& x, const contiguous_iterator& y) {
+    return x.it_ >= y.it_;
+  }
 
     // Note no operator<=>, use three_way_contiguous_iterator for testing operator<=>
 
-    friend constexpr It base(const contiguous_iterator& i) { return i.it_; }
+  friend constexpr It base(const contiguous_iterator& i) { return i.it_; }
 
-    template <class T>
-    void operator,(T const &) = delete;
+  template <class T>
+  void operator,(T const&) = delete;
 };
 template <class It>
 contiguous_iterator(It) -> contiguous_iterator<It>;

``````````

</details>


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


More information about the libcxx-commits mailing list