[libcxx-commits] [libcxx] [libc++] Fix complexity guarantee in std::clamp (PR #68413)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 9 11:25:02 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);
----------------
EricWF wrote:
I would much rather we simply pass the projection down to another function, which ensures the lifetime of the projection, even in weird cases.
https://github.com/llvm/llvm-project/pull/68413
More information about the libcxx-commits
mailing list