[libcxx-commits] [libcxx] [libc++] Backport segmented iterator optimization for std::for_each to C++03 (PR #134960)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 10 12:55:47 PDT 2025


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 HEAD~1 HEAD --extensions ,cpp,h -- libcxx/include/__algorithm/for_each.h libcxx/include/__algorithm/for_each_segment.h libcxx/include/algorithm libcxx/include/array libcxx/include/bitset libcxx/include/codecvt libcxx/include/condition_variable libcxx/include/ios libcxx/include/locale libcxx/include/streambuf libcxx/include/string libcxx/include/string_view libcxx/include/system_error libcxx/include/vector libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp
``````````

</details>

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

``````````diff
diff --git a/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp b/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp
index 87bbfae94..fac7ce22e 100644
--- a/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp
@@ -211,17 +211,21 @@ TEST_CONSTEXPR_CXX20 bool all_the_algorithms()
 }
 
 bool test_segmented_iterator() {
-    int copies = 0;
-    std::deque<int> dq(10);
-    (void)std::for_each(dq.begin(), dq.end(), UnaryVoid<int>(&copies)); assert(copies == 1); copies = 0;
+  int copies = 0;
+  std::deque<int> dq(10);
+  (void)std::for_each(dq.begin(), dq.end(), UnaryVoid<int>(&copies));
+  assert(copies == 1);
+  copies = 0;
 
 #if TEST_STD_VER >= 20
-    std::vector<std::vector<int>> vecs(3, std::vector<int>(10));
-    auto v = std::views::join(vecs);
-    std::for_each(v.begin(), v.end(), UnaryVoid<int>(&copies)); assert(copies == 1); copies = 0;
+  std::vector<std::vector<int>> vecs(3, std::vector<int>(10));
+  auto v = std::views::join(vecs);
+  std::for_each(v.begin(), v.end(), UnaryVoid<int>(&copies));
+  assert(copies == 1);
+  copies = 0;
 #endif
 
-    return true;
+  return true;
 }
 
 int main(int, char**)

``````````

</details>


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


More information about the libcxx-commits mailing list