that the max() template according to [StepanovNotes] intentionally returns “b < a ? a : b” instead of “a < b ? b : a” to ensure that the function behaves correctly even if the two values are equivalent but not equal." т.е. если значения еквивалентны ты вернет B. но на cppref для std::max написано что вернет A. wtf?
в MSC if (_Left < _Right) { return _Right; }
Requires: For the first form, type T shall be Cpp17LessThanComparable ([tab:lessthancomparable]Table *tab:lessthancomparable). 10 # Returns: The larger value. 11 # 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. 12 # Complexity: Exactly one comparison and two applications of the projection, if any.
Правильно вернуть а
Обсуждают сегодня