jeudi 30 avril 2020

How to std::tie to unpack results of std::minmax_element?

I have a container v of elements of type T, to which I apply std::minmax_element, like so:

auto min_max = std::minmax_element(v.begin, v.end);
auto min = min_max.first;
auto max = min_max.second;

I would like to unpack the results of std::minmax_element with std::tie, but I can't figure the type for the declaration:

*type?* first_it, last_it;
std::tie(first_it, last_it) = std::minmax_element(v.begin, v.end);

What would be the type of first_it and last_it?

Aucun commentaire:

Enregistrer un commentaire