Why create a function like boost and std minmax that returns a pair, both of the same type. when you could return a vector and have the possibility of access to them with index.
If: vectores need .size()..., pair<> are exactly 2 elements... means less space...
Then why pair return first, and second. and not just a container with index.
auto result = std::minmax_element (foo.begin(),foo.end());
std::cout << "min is " << *result.first;
std::cout << ", at position " << (result.first-foo.begin()) << '\n';
std::cout << "max is " << *result.second;
std::cout << ", at position " << (result.second-foo.begin()) << '\n';
think about this, is not the best example. but... remember intelligence is: maximize the possibilities. and this opens possibilities.
for(uint64_t i = 0; i < 2; ++i) {
if (i)
std::cout << "max is ";
else
std::cout << "min is ";
std::cout << *result[i];
std::cout << ", at position " << (result[i]-foo.begin()) << '\n';
}