News for hackers. Stuff that matters.
Re:Maximal Min() and Max() by wahern on Thursday August 08, 2024 @03:22PM (#41195217)
The specific macro discussed in the article is using various GCC builtins to safely support mixed integer types; i.e. failing on unsafe type promotions or coercion, but otherwise working automagically. C++ std:min, by contrast, requires all the values to be the same type. AFAIU, to accomplish the same semantics in C++ would require either template metaprogramming, or doing something similar to what the current version is doing with macros and GCC builtins. A C++ solution might ultimately be cleaner, but I don't think there's anything in the standard C++ library that is a drop-in replacement.
Re:Maximal Min() and Max() by creeble on Friday August 09, 2024 @12:28PM (#41203310)
Nor would it perform well during compilation, which is very well discussed in the thread. C++ compilation is slow, like the macro expansion of the C versions of min and max.

It’s all in the thread, I don’t know how GP missed it.