<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110660>110660</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] modernize-use-ranges does not properly handle std::sort
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
felix642
</td>
</tr>
</table>
<pre>
Assume the following code:
```
#include <vector>
#include <algorithm>
struct Bar
{
int a;
bool operator< (const Bar& rhs) const
{
return a < rhs.a;
}
};
void foo()
{
std::vector<Bar> bar;
std::sort(bar.begin(), bar.end());
}
```
the check `modernize-use-ranges` will suggests to replace `std::sort` with `std::ranges::sort`, but this would not compile since `bar` does not have `weak_ordering` which is a requirement for `std::ranges::sort`.
godbolt: https://godbolt.org/z/GWG5K3fh9
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU81u6joQfhpnMyJynJCQRRYUShf3Ae7yyrEnsW8dm2M7cNqnP3KAQiukI6Gxmb_v8zcZHoIeLWJH1i9kvc_4HJXz3YBG_64rlvVOfnTbEOYJISqEwRnjztqOIJxEUm4J3RO6JTW9_i5_WamtMLNEIOXuhCI6T8rXZ0FuRud1VNM9vtgQ_SwivHB_9TYvlwsAgLYROCkfPL1zBtwRPV-gdkDYRjgbLh1YDV4FwlpYfDec9qtputPWY5y9BZ54pYL8jrEk729U9g_-ZE9OSxicI2xDWPuEcIgyaVVub1rsEq3yFfp0PEsMzkfCNj33eY-jttfWbJdKcrTy5mjvXL4I_pjGYtP0hELxDqSmk5Porf7E1Rxw5bkdMZCawlkbA2EeRwwxQHTg8Wi4wFTzndqSHNW3wLXPY9JCeI4QlQ5wdrORYF0E4aajNghB20vzpENNQToMS4Lip8V_Rv7-n_MSvbbjAqq0UKADcPD4a9YeJ7QRBuf_RiV_VGN0sncmknILKsbjkskOhB2ugdz5kbDDJ2GHt3_f1v-Ug2oz2ZWyLVueYVc0rGk2TVXWmeqKGnusEWkzbNpmXTRVixVlPTJZDaLnme4YZVVBaVGwdVPUecNE2W_Eeihr5O0gSUVx4trkxpymhJ3pEGbsioLWNc0M79GEZUcZE4bbcRW1_CCMpZ31Xapa9fMYSEWNDjHc-0QdzbLdD2XrPTz7AO7qH31aJfMBiluZxvQ4-mz2pvshmo5q7nPhJsIOCfp6rI7e_Y8iEnZY3hMIO1yfdOrYnwAAAP__c5lXSg">