3 ms·
They do not address the question at all. Please write an answer yourself.
by jonathrg 2y ago
They do not address the question at all. Please write an answer yourself.
- wahern 2y agoThe 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.
- creeble 2y agoNor 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.