<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61663>61663</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
libc++ should diagnose when std::sort & friends is used with a non strict-weak order
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ldionne
</td>
</tr>
</table>
<pre>
We emit a `diagnose_if` warning in C++20 mode when users call `std::sort` (or other sort-like algorithms) on e.g. floating points with `std::less`, which technically doesn't satisfy a strict weak ordering. There are probably other cases, like `std::greater` and also many more algorithms like `std::partition` and friends.
We could introduce a new heuristic trait like `__is_definitely_not_valid_strict_weak_ordering<Comparator, T, U>`, and that would be true for `std::less`, `std::greater` & friends when used with floating point types.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0k82OozoQhZ_GbEqNiElDWLDo7rl5grmaJSpwAXXH2JGrmChvf0V-pjsazcZISOf4fMdVKMJTIGrN67t5_ZbhqnNMrXccQ6Csj-7S_iCghRUQTFU4xilEoY5HUxVwxhQ4TMABPox9N_bdFrBER3CeKcAqlAQG9H7TijpTvpnyTWLSTW3sISaIOlOC7d-L558E6KeYWOdFjG0gBqB8ymH0EXW76hQ5qMCZdX4y9SRiqsLYDzjPPMygNMyBt8sv4CJJMLZWEFSW8QIIookHhTPhT4jJUeIw5fB9pkSAieCUYo-9v9wDDigkm_s15Nebp0SolDYiDA7QS4QFwwWWmL7i_Kk8YVJWjuGhHRNTcJKb4psp3m7nD4Ihrt4BB03RrQMBQqAzzLQmFuUBNCHrb_uuY-kcjRxYyV-6ELX7hZ5dd0PuNuTugWzKj4-4nDChxrTxfd-Of035z73NLZfOqHC-pugJNK0EY0x_6_8v5RhbPQB_j4e7PeTz64JeTiR55trSNWWDGbW7qm5eG7tv6mxurXXjQLjfj4fhUFS78tAPddNT46p617_ajFtb2LIobbmr7WFX53g4jFQ0ddU3Q9lYa_YFLcg-9_7Xksc0ZSyyUlvtqqrMPPbk5boT1nruh9toG2u3HUntJnrp10nMvvAsKp82yuqp_dSAzNfWHntzA3_ahKdeWL60ghBiuM_py-ecZmvy7ax6ks3EHo09Tqzz2udDXIw9bmHun5dTiv_RoMYer4Bi7PHK-H8AAAD__-MMT3s">