I am experimenting with std::max. I am tring to pass integers constexpr with uniform initialization (curly braces), to compare them to floating-point variables.
Experiment a): Call std::max() with double/int mixed
double a = 3.0;
int b = 5;
auto res = std::max(a, b);
Does not compile. Clang reports error: no matching function for call to 'max'. This is of course OK.
Experiment b): Use curly braces + constexpr int for non-anrrowing conversion
double a = 3.0;
constexpr int b = 5;
auto res = std::max(a, {b});
Compiles and works as expected: returns a double with value 5.0.
Experiment c): Same as b) but swap arguments of std::max.
double a = 3.0;
constexpr int b = 5;
auto res = std::max({b}, a);
Does not compile both under gcc and clang. Why?
Clang reports error: called object type 'double' is not a function or function pointer.