#include <algorithm>
#include <vector>
int main() {
std::vector<int> v;
auto cmp = [](int&, int&) { return true; };
std::ranges::sort(v, cmp);
std::ranges::inplace_merge(v, v.begin(), cmp); // hard error
}
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 as ranges::sort.
The root cause is that inplace_merge uses upper_bound, which then requires Compare to satisfy indirect_strict_weak_order<const T*, I> (note the const here), which is not guaranteed by the constraints of inplace_merge.
https://godbolt.org/z/soe8sa75q
The above code is rejected by libstdc++, libc++, and MSVC-STL, which shouldn't be because
ranges::inplace_mergehas the same constraint signature asranges::sort.The root cause is that
inplace_mergeusesupper_bound, which then requiresCompareto satisfyindirect_strict_weak_order<const T*, I>(note theconsthere), which is not guaranteed by the constraints ofinplace_merge.