-
Notifications
You must be signed in to change notification settings - Fork 13.4k
<algorithm>
: ranges::find_if_not
's help lambda should return bool
#69074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Did you encounter this in real code? |
No, just like I have never encountered an iterator that overloads the comma operator in real life. Note that |
I suspect @philnik777 was asking out of curiosity. I agree this is kinda pedantic but it's worth fixing. |
I believe there are still helper lambdas like this in libc++, such as |
I think we could/should tackle all of them via this issue and #69378. Can you think of a good way to find all of them? I guess we need to look at all the ranges algorithms that take a predicate, since they all expect the predicate to return a |
Sadly that seems to be the case. |
I was looking at what we do in
directly in the calling algorithm. Are you able to find a case where e.g. |
Edit: Sorry I am on a plane and connection is flaky, I thought I had lost my previous comment. Anyway, I did a full survey of everything in
|
Yes, I can find it. testcase: https://godbolt.org/z/sPzo6o565
At least I think |
The following test is the |
…e correctly Before this patch, we would fail to implicitly convert the result of predicates to bool, which means we'd potentially perform a copy or move construction of the boolean-testable, which isn't allowed. The same holds true for comparing iterators against sentinels, which is allowed to return a boolean-testable type. We already had tests aiming to ensure correct handling of these types, but they failed to provide appropriate coverage in several cases due to guaranteed RVO. This patch fixes the tests, adds tests for missing algorithms and views, and fixes the actual problems in the code. Fixes llvm#69074
…e correctly (#69378) Before this patch, we would fail to implicitly convert the result of predicates to bool, which means we'd potentially perform a copy or move construction of the boolean-testable, which isn't allowed. The same holds true for comparing iterators against sentinels, which is allowed to return a boolean-testable type. We already had tests aiming to ensure correct handling of these types, but they failed to provide appropriate coverage in several cases due to guaranteed RVO. This patch fixes the tests, adds tests for missing algorithms and views, and fixes the actual problems in the code. Fixes #69074
llvm-project/libcxx/include/__algorithm/ranges_find_if_not.h
Lines 46 to 51 in 8dd3bc1
The lambda here should specify the return type as
bool
, such as[&](auto&& __e) -> bool
because the type that satisfiesboolean-testable
does not necessarily have to bebool
:https://godbolt.org/z/4M15cvarx
The text was updated successfully, but these errors were encountered: