[libcxx-commits] [libcxx] [libc++] Make sure ranges algorithms and views handle boolean-testable correctly (PR #69378)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 1 15:45:34 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 801c78d5b474c2319aa8ead44db7ba8cacac4714 cd5d4c06b4d78a5dfa1faf6377fe3a047fc73872 -- libcxx/test/std/algorithms/ranges_robust_against_nonbool.compile.pass.cpp libcxx/test/std/ranges/range.adaptors/robust_against_nonbool.compile.pass.cpp libcxx/test/std/utilities/memory/specialized.algorithms/ranges_robust_against_nonbool.compile.pass.cpp libcxx/include/__algorithm/ranges_find_if_not.h libcxx/include/__algorithm/ranges_max.h libcxx/include/__algorithm/ranges_max_element.h libcxx/include/__algorithm/ranges_remove.h libcxx/include/__algorithm/ranges_remove_copy.h libcxx/include/__algorithm/ranges_replace.h libcxx/include/__algorithm/ranges_replace_copy.h libcxx/include/__algorithm/ranges_upper_bound.h libcxx/include/__ranges/chunk_by_view.h libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/ranges.remove.pass.cpp
``````````

</details>

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

``````````diff
diff --git a/libcxx/include/__algorithm/ranges_max.h b/libcxx/include/__algorithm/ranges_max.h
index 6e207ab5153c..782ce2670f05 100644
--- a/libcxx/include/__algorithm/ranges_max.h
+++ b/libcxx/include/__algorithm/ranges_max.h
@@ -72,7 +72,9 @@ struct __fn {
     _LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range must contain at least one element");
 
     if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {
-      auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
+      auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool {
+        return std::invoke(__comp, __rhs, __lhs);
+      };
       return *ranges::__min_element_impl(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj);
     } else {
       range_value_t<_Rp> __result = *__first;

``````````

</details>


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


More information about the libcxx-commits mailing list