[clang-tools-extra] [libc++] Fix complexity guarantee in ranges::clamp (PR #68413)

Louis Dionne via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 07:11:09 PDT 2023


================
@@ -37,9 +37,10 @@ struct __fn {
     _LIBCPP_ASSERT_UNCATEGORIZED(!bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))),
                                  "Bad bounds passed to std::ranges::clamp");
 
-    if (std::invoke(__comp, std::invoke(__proj, __value), std::invoke(__proj, __low)))
+    auto&& __projected = std::invoke(__proj, __value);
----------------
ldionne wrote:

Ahhhh, yes, indeed. So then I don't see a way that we can make this "work" even if we wanted to.

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


More information about the cfe-commits mailing list