[clang-tools-extra] [libc++] Prevent calling the projection more than three times (PR #66315)
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 15 13:05:32 PDT 2023
================
@@ -108,7 +108,33 @@ constexpr bool test() {
auto prvalue_proj = [](const CheckDoubleMove& x) -> CheckDoubleMove { return x; };
assert(&std::ranges::clamp(val, low, high, moving_comp, prvalue_proj) == &val);
}
+ { // Make sure we don't call the projection more than three times per [alg.clamp], see #64717
+ int counter = 0;
+ auto projection_function = [counter](const int value) -> int {
----------------
ldionne wrote:
```suggestion
auto projection_function = [&counter](const int value) -> int {
```
Otherwise the test might not work if we copy the projection itself!
https://github.com/llvm/llvm-project/pull/66315
More information about the cfe-commits
mailing list