The output will be:
1111
This is due to [alg.min.max]p3 which says:
Remarks: Returns the first argument when the arguments are equivalent. An invocation may explicitly specify an argument for the template parameter T of the overloads in namespace std.
and [alg.min.max]p11 which says:
Remarks: Returns the first argument when the arguments are equivalent. An invocation may explicitly specify an argument for the template parameter T of the overloads in namespace std.
So both std::max
and std::min
return the first argument when they are equivilent. Sean Parent discusses this issue in his CppNow 2016 Keynote: Better Code where he considers this a defect.
std::minxmax()
does better here and if they are equivalent min is the first and max is the second, see [alg.min.max]p19.
This was also added to CppQuiz as a question.