-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<algorithm>
: ranges::inplace_merge
doesn't seem to be able to utilize ranges::upper_bound
#4863
Comments
<algorithm>
: ranges::implace_merge
doesn't seem to be able to utilize ranges::upper_bound
<algorithm>
: ranges:: inplace_merge
doesn't seem to be able to utilize ranges::upper_bound
<algorithm>
: ranges:: inplace_merge
doesn't seem to be able to utilize ranges::upper_bound
<algorithm>
: ranges::inplace_merge
doesn't seem to be able to utilize ranges::upper_bound
<algorithm>
: ranges::inplace_merge
doesn't seem to be able to utilize ranges::upper_bound
<algorithm>
: ranges::inplace_merge
doesn't seem to be able to utilize ranges::upper_bound
Pedantically wrong for all three major implementations. Implementations actually call the unconstrained (by possible At the first glance, I thought we should remove |
Not sure if making |
@barcharcraz and I talked about this at the weekly maintainer meeting. The fact that the Majestic Three implementations all reject this code, and the fact that it seems super pathological/useless for comparison function objects to reject |
OK. Let me change the example that is only rejected by MSVC-STL: #include <algorithm>
#include <vector>
struct S {
operator int();
};
int main() {
std::vector<int> v;
auto cmp = [](const int&, const int&) { return true; };
std::ranges::inplace_merge(v, v.begin(), cmp, [](int) { return S{}; });
} https://godbolt.org/z/M1z8aaq9s Could this be considered a library bug? |
Yeah, that looks more like a bug to me, since MSVC is alone there (with the nitpicks that a "do nothing" comparator really ought to return |
For the LWG issue part, LWG-3031 seems roughly related. |
Quoted from LWG-3031:
Doesn't this already indicate that this is a bug in the standard library implementation rather than a defect in the standard? |
I didn't know what the paragraph intended to mean. |
https://godbolt.org/z/soe8sa75q
The above code is rejected by libstdc++, libc++, and MSVC-STL, which shouldn't be because
ranges::inplace_merge
has the same constraint signature asranges::sort
.The root cause is that
inplace_merge
usesupper_bound
, which then requiresCompare
to satisfyindirect_strict_weak_order<const T*, I>
(note theconst
here), which is not guaranteed by the constraints ofinplace_merge
.The text was updated successfully, but these errors were encountered: