auto [x, y] = std::minmax(a, b)
defines x
and y
as references to a
and b
(or b
and a
).
How do I make x
and y
new variables initialized with min and max values respectively (as if minmax
returned pair of values instead of pair of refs)?
CodePudding user response:
You can use the overload of the std::initializer_list
version, which returns pair<T, T>
.
auto [x, y] = std::minmax({a, b});