You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
The check modernize-use-ranges will flag the following code :
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 aminmax_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.
The text was updated successfully, but these errors were encountered: