<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64717>64717</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] `std::ranges::clamp` violates [alg.clamp]p5
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fulgen301
</td>
</tr>
</table>
<pre>
[alg.clamp]p5 mandates the complexity requirements for `std::ranges::clamp` to be at most two comparisons and three applications of the projection. libc++ however applies the projection four times. [See godbolt.](https://godbolt.org/z/cE1WGcY1j)
https://github.com/llvm/llvm-project/blob/5ed62c7bc99a979261d34e41aaca9581577674bf/libcxx/include/__algorithm/ranges_clamp.h#L40-L43
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUUj2P3CAQ_TXjBp2FxwYvhYtbbZzmuhRRqhPgWZsTNg7g-8ivj-y900lJEaUBNMO8efPm6ZTcuBB1IM4gLoXe8hRi129-pKXmVWHC8LYntR9L6_W8grisgs16GXSmxPJEzIZ59fTq8huL9HNzkWZacmLXEBlInvIA9T3U91EvI6Xb-4YlOcuBGWI6szmkzPJLOOB0dCksiellYHmKREyvq3dWZ7eHw_VovMbwRHYPlcw7YwHPgGc2hRd6pngreef4-ZVdwxZZdjOlkoE4fyNiYxhM8LkEcQE8TTmvB03sAfuPXIgjYP8LsLdfqu9f7Y_qCVABvwC_v51_1Lk8baa0YQbsvX_-uO7eqQD2xgcD2AsaJNrWWKW0ahXKaqgbaiqtrVbiVIm2lW1jrjuAM_b1FbB3i_XbQID946P2Y4guT3uHm8aPh7zlBFg_NPzuoamLoasHVStdUFdJhVVdY6OKqZOaY62V5FJJwVFUqPCqydTXEworTeE65FjzUyWw4rxpy9aekEupqGmJZCOg4TRr58t9ul2mwqW0USebtmoLrw35dPgLcaEXdiQBcbdb7A5FzDYmaLh3KadPlOyyP4z5uVoQl3876tkFf3jzL9sWW_Tdf2_pIJwA-2Og3wEAAP__L58ELQ">