Reputation: 29962
With the new features of C++17, is it possible to create a better std::min
and std::max
?
What I mean by better:
std::min/max
has the problem of dangling references.std::min/max
doesn't work with different types (i.e., min(short, int)
needs to explicitly specify the type min<int>(...)
)I'd like to have a better implementation, which:
min(a, 4);
works correctly)min((short)4, (int)8);
compiles)Is it possible to do this, or is std::min/max
the current best solution which one can have?
Upvotes: 0
Views: 551
Reputation: 218900
Here's an old and failed proposal for a better min
/max
using just C++11 tech:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2199.html
Upvotes: 5