5 ms·
They said C++, but aside from the line containing "std::max," they wrote C code, and what they said applies to C as well.
by trealira 3y ago
They said C++, but aside from the line containing "std::max," they wrote C code, and what they said applies to C as well.
- gosub100 3y agothen why not post a standard C example?
- Const-me 3y agoIf I would rework that snippet to be in C instead of C++, that code would no longer be my today’s WTF. Also, IMO `std::max` is more readable than the equivalent conditional operator.
- gosub100 3y agoIts irrelevant and a different language. might as well post ocaml or julia
- Const-me 3y agoVery relevant. Apart from a few minor exceptions, C++ is a superset of C i.e. almost any C code can be compiled as C++ language, and will result in a correct program.
- ryao 3y agoTry compiling C code using union types for their intended type punning purpose as C++. It will compile, but bad things could happen. :/
- ryao 3y agoIf the C++ compiler takes it, it is C++ code. The fact that it is almost valid C code does not change that. The reactions a number of people have to C++ code that is also valid C code or close to being it are ridiculous. Some times, they even deny C++ code is C++ code. :/
- trealira 3y agoI was just saying that it's not off-topic. I don't really understand what you're trying to say otherwise.