Example 1 — Two values
Get both values in order.
#include <algorithm>
#include <iostream>
int main() {
int a = 3;
int b = 8;
auto r = std::minmax(a, b);
std::cout << "min=" << r.first << " max=" << r.second << '\n';
return 0;
} How It Works
minmax()returns a pair of references toaandb.r.firstrefers to the smaller one, 3.r.secondrefers to the larger one, 8.

