[libcxx-commits] [libcxx] [libc++] Fix complexity guarantee in std::clamp (PR #68413)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 26 07:31:32 PDT 2023
================
@@ -82,31 +93,29 @@ constexpr bool test() {
auto low = S{20};
auto high = S{30};
// Check that the value category of the projection return type is preserved.
- assert(&std::ranges::clamp(val, low, high, Comp{}, &S::lvalue_proj) == &low);
----------------
ldionne wrote:
The test above which does:
```
std::same_as<const int&> decltype(auto) ret = std::ranges::clamp(val, low, high);
assert(ret == 2);
assert(&ret == &val);
```
is the one that checks that we return a reference to the right object. This comparing of addresses was basically not necessary AFAICT.
https://github.com/llvm/llvm-project/pull/68413
More information about the libcxx-commits
mailing list