[libcxx-commits] [libcxx] Libcxx ranges contains subrange (PR #76760)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 2 14:45:50 PST 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 67c2e354c3f0326947914c097bf68997ac5065b2 ae96c2f72baaddc9dd121cd645b15b45a44c23a6 -- libcxx/include/__algorithm/ranges_contains_subrange.h libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp libcxx/include/algorithm libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
``````````

</details>

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

``````````diff
diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h b/libcxx/include/__algorithm/ranges_contains_subrange.h
index d4fcb8c08a..e629271628 100644
--- a/libcxx/include/__algorithm/ranges_contains_subrange.h
+++ b/libcxx/include/__algorithm/ranges_contains_subrange.h
@@ -81,8 +81,8 @@ struct __fn {
       _Pred __pred   = {},
       _Proj1 __proj1 = {},
       _Proj2 __proj2 = {}) const {
-    int __n1     = ranges::distance(__first1, __last1);
-    int __n2     = ranges::distance(__first2, __last2);
+    int __n1 = ranges::distance(__first1, __last1);
+    int __n2 = ranges::distance(__first2, __last2);
     if (__n2 == 0)
       return true;
     int __offset = __n1 - __n2;
diff --git a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp b/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp
index cc031867b9..71823d9afc 100644
--- a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp
@@ -86,8 +86,10 @@ constexpr bool all_the_algorithms()
     assert(copies == 0);
     (void)std::ranges::contains(a, value, Proj(&copies));
     assert(copies == 0);
-    (void)std::ranges::contains_subrange(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0);
-    (void)std::ranges::contains_subrange(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0);
+    (void)std::ranges::contains_subrange(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies));
+    assert(copies == 0);
+    (void)std::ranges::contains_subrange(a, b, Equal(), Proj(&copies), Proj(&copies));
+    assert(copies == 0);
 #endif
     (void)std::ranges::count(first, last, value, Proj(&copies)); assert(copies == 0);
     (void)std::ranges::count(a, value, Proj(&copies)); assert(copies == 0);
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp
index 0b7a2359b2..34caf23e9c 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp
@@ -49,7 +49,8 @@ static_assert(!HasContainsSubrangeIt<int*, int*, int*, SentinelForNotWeaklyEqual
 
 template <class Range1, class Range2 = UncheckedRange<int*>>
 concept HasContainsSubrangeR = requires(Range1&& range1, Range2&& range2) {
-  std::ranges::contains_subrange(std::forward<Range1>(range1), std::forward<Range2>(range2)); };
+  std::ranges::contains_subrange(std::forward<Range1>(range1), std::forward<Range2>(range2));
+};
 
 static_assert(HasContainsSubrangeR<UncheckedRange<int*>>);
 static_assert(!HasContainsSubrangeR<ForwardRangeNotDerivedFrom>);
@@ -64,7 +65,7 @@ static_assert(!HasContainsSubrangeR<UncheckedRange<int*>, ForwardRangeNotSentine
 
 template <class Iter1, class Sent1 = Iter1, class Iter2, class Sent2 = Iter2>
 constexpr void test_iterators() {
-  {  // simple tests
+  { // simple tests
     int a[]       = {1, 2, 3, 4, 5, 6};
     int p[]       = {3, 4, 5};
     auto whole    = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
@@ -232,10 +233,10 @@ constexpr void test_iterators() {
   }
 
   { // check that the projections are used
-    int a[]        = {1, 3, 15, 1, 2, 1, 8};
-    int p[]        = {2, 1, 2};
-    auto whole     = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 7)));
-    auto subrange  = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+    int a[]       = {1, 3, 15, 1, 2, 1, 8};
+    int p[]       = {2, 1, 2};
+    auto whole    = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 7)));
+    auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
     {
       bool ret = std::ranges::contains_subrange(
           whole.begin(),

``````````

</details>


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


More information about the libcxx-commits mailing list