<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110593>110593</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Invalid Fix-it modernize-use-ranges
</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>
The check modernize-use-ranges will flag the following code :
```
#include <vector>
#include <algorithm>
#include <iostream>
void foo()
{
std::vector<int> my_vector = {1, 2, 3, 4, 5};
auto min_max = std::minmax_element(my_vector.begin(), my_vector.end()); // warning: use a ranges version of this algorithm [modernize-use-ranges]
std::cout << *min_max.first << " " << *min_max.second << '\n';
}
```
But the return value of std::minmax_element and std::ranges::minmax_element are not the same. The first one returns a `std::pair<ForwardIt, ForwardIt>` while the second one returns a `minmax_element_result<I>`.
This means that applying the proposed Fix-It will break the code.
godbolt: https://godbolt.org/z/3rTW78e8x
I do not think there is a simple way to update the code from std::minmax_element to std::ranges::minmax_element so I would suggest to simply diagnose the problem but let the user fix it.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVEuPqzoM_jXpxiqiSQvtgkUfU6n7ke5yFIiB3BMSlEcf59dfBejj3OlIR2oNxPH32Z-dcOdkoxELstqR1WHGg2-NLWpU8pot6aw04lZ8tghVi9Uv6IxAq-VvnAeHc8t1gw4uUimoFW_Atwi1UcpcpG6gMgKBsC2Q9EDS7WSzdPqNn5RJXakw7NyfsfLGEvbxzslVY6z0bfeDXxrnLfIX92DPRgqojSF0Tehm8uS78QUAwHlB2Jaw7Z19L7Un7AO629e4BIQdgOS7BaF7oNGwaJbRrEh-IOwFjgdvoJP6q-PXIfCB30nd8esXKuxQe0LXD4KkxEbqKUO6fzInqMV9eUPYDgg9EnqEC7da6iaKGxwCh6kVZ7ROGg2mBt9KBw_NgKx275pHVoc3SlQm-CgpYXsgdDtVk9TSupd1Ov6_bXNYGS2ejpys9jo-7jJFyd4Nwy74YYQs-mA1nLkKGEv5QUHgWjx9Uz1v91kEbUZsxztMIE70WI3Rdz4HHEiWPgB7LuMwHI29cCtOPjbm-cE-SJbCpZUKR9yx6G9wf6byZdEF5Qnbn0aE5HVUP2PLOuTagW-5B9736hZPUiToremNQwFHeZ2f_HjqSov81-COh-0PsMaI0kSqLbTe94Myw_BMjsTYhtDjb0KPzH7-k69xfX2NP4Ewk2pSDxwWIY4UONn1CuHCb-ANhF5wj48coLam-7Fj3vxVw5yBE1xMUAJcaBp0Y2TkvYGQvNHG4V2VUmEHZfCgcGxxcGihlleQPpmJgokN2_AZFouc5jnLUprN2mKTr9O8xFywerlcUsyYSGmWLdJVies1z2ayoCldphuWUrpMaZaseVplrFqUlHO6ySlZpthxqRKlzl1UcyadC1gsFulqw2aKl6jccK9SWimum7mX4kYojfesLWLUvAyNI8tUSefdE8dLr4Yb-SVsdYCTPnMlxwGQ_u1dPAtWFf9rt_RtKJPKdIQeI8X0mPfW_IuVJ_Q45O0IPU6pnwv6XwAAAP__PljqRA">