Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They do not address the question at all. Please write an answer yourself.


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.


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.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: