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/maxhas the problem of dangling references.std::min/maxdoesn't work with different types (i.e.,min(short, int)needs to explicitly specify the typemin<int>(...))
I'd like to have a better implementation, which:
- avoids the dangling reference problem (for example, 
min(a, 4);works correctly) - works with different types (for example, 
min((short)4, (int)8);compiles) - avoids unnecessary object copies (for example, if I have a class which represents a big integer, it only copies it when it is unavoidable)
 
Is it possible to do this, or is std::min/max the current best solution which one can have?