[libcxx-commits] [libcxx] [libc++] Fix _CopySegment helper in ranges::copy(join_view, out) when called in a static assertion context (PR #69593)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 23 00:20:11 PDT 2023


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 a9136f0ad94bf7738c585c6d12ad5bbe1815f95b 8f4f90a925d63a975de17df0bd89460b545f7dc0 -- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.segmented.pass.cpp libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_n.segmented.pass.cpp libcxx/test/std/algorithms/alg.modifying.operations/alg.move/ranges.move.segmented.pass.cpp libcxx/test/std/algorithms/alg.modifying.operations/alg.move/ranges.move_backward.segmented.pass.cpp libcxx/include/__algorithm/copy.h libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
``````````

</details>

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

``````````diff
diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h
index 15a45a3ed8c9..b35c6fa04a38 100644
--- a/libcxx/include/__algorithm/copy.h
+++ b/libcxx/include/__algorithm/copy.h
@@ -51,8 +51,8 @@ struct __copy_loop {
 
     _OutIter& __result_;
 
-    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
-    explicit _CopySegment(_OutIter& __result) : __result_(__result) {}
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit _CopySegment(_OutIter& __result)
+        : __result_(__result) {}
 
     _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
     operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.segmented.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.segmented.pass.cpp
index 6856e19a6504..c434cea1208c 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.segmented.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.segmented.pass.cpp
@@ -95,9 +95,7 @@ constexpr void test_join_view() {
 constexpr bool test_constexpr() {
   test_containers<std::vector<int>, std::vector<int>>();
 
-  types::for_each(types::bidirectional_iterator_list<int*>{}, []<class Iter> {
-    test_join_view<Iter, Iter>();
-  });
+  types::for_each(types::bidirectional_iterator_list<int*>{}, []<class Iter> { test_join_view<Iter, Iter>(); });
   return true;
 }
 
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_n.segmented.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_n.segmented.pass.cpp
index cdbb2ae1e535..eae40cefa663 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_n.segmented.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_n.segmented.pass.cpp
@@ -50,7 +50,9 @@ constexpr void test_join_view() {
     std::vector<std::ranges::subrange<Iter, Sent>> subrange_vector(range.begin(), range.end());
     std::array<int, 0> arr;
 
-    std::ranges::copy_n((subrange_vector | std::views::join).begin(), std::ranges::distance(subrange_vector | std::views::join), arr.begin());
+    std::ranges::copy_n((subrange_vector | std::views::join).begin(),
+                        std::ranges::distance(subrange_vector | std::views::join),
+                        arr.begin());
     assert(std::ranges::equal(arr, std::array<int, 0>{}));
   }
   { // segmented -> contiguous
@@ -59,7 +61,9 @@ constexpr void test_join_view() {
     std::vector<std::ranges::subrange<Iter, Sent>> subrange_vector(range.begin(), range.end());
     std::array<int, 10> arr;
 
-    std::ranges::copy_n((subrange_vector | std::views::join).begin(), std::ranges::distance(subrange_vector | std::views::join), arr.begin());
+    std::ranges::copy_n((subrange_vector | std::views::join).begin(),
+                        std::ranges::distance(subrange_vector | std::views::join),
+                        arr.begin());
     assert(std::ranges::equal(arr, std::array{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
   }
   { // contiguous -> segmented
@@ -79,7 +83,9 @@ constexpr void test_join_view() {
     auto range2                              = to_vectors | to_subranges;
     std::vector<std::ranges::subrange<Iter, Sent>> to_subrange_vector(range2.begin(), range2.end());
 
-    std::ranges::copy_n((subrange_vector | std::views::join).begin(), std::ranges::distance(subrange_vector | std::views::join), (to_subrange_vector | std::views::join).begin());
+    std::ranges::copy_n((subrange_vector | std::views::join).begin(),
+                        std::ranges::distance(subrange_vector | std::views::join),
+                        (to_subrange_vector | std::views::join).begin());
     assert(std::ranges::equal(to_subrange_vector | std::views::join, std::array{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
   }
 }
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/ranges.move_backward.segmented.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/ranges.move_backward.segmented.pass.cpp
index 809488b39f6f..0f0a71439a10 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/ranges.move_backward.segmented.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/ranges.move_backward.segmented.pass.cpp
@@ -95,9 +95,7 @@ constexpr void test_join_view() {
 constexpr bool test_constexpr() {
   test_containers<std::vector<int>, std::vector<int>>();
 
-  types::for_each(types::bidirectional_iterator_list<int*>{}, []<class Iter> {
-    test_join_view<Iter, Iter>();
-  });
+  types::for_each(types::bidirectional_iterator_list<int*>{}, []<class Iter> { test_join_view<Iter, Iter>(); });
   return true;
 }
 

``````````

</details>


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


More information about the libcxx-commits mailing list