As explained in other answers, the reason is that std::min requires the argument types to be identical if deduction is to be performed, whereas < implies the usual arithmetic conversions (Β§5.9 / 2), which will make sure that the types are converted to "common denominator". Please note that Β§13.6 / 12 lists the built-in operators as candidates:
For each pair of advanced arithmetic types L and R there is a candidate operator operator of the form
where LR is the result of ordinary arithmetic conversions between types L and R
Actually, std::min must deal with various types. Below is a more modern approach:
template <typename T> constexpr decltype(auto) min(T&& t) {return std::forward<T>(t);} template <typename T, typename U, typename... Args> constexpr auto min(T&& t, U&&u, Args&&... args) { std::common_type_t<T, U> const& _t(std::forward<T>(t)), _u(std::forward<U>(u)); return min(_t<_u? _t : _u, std::forward<Args>(args)...); }
Demo
Columbo
source share