4 ms·
I think "just as well" elides maintainability... I would not want to have to debug a generic sorter written in c preprocessor.
by throwawaymaths 4y ago
I think "just as well" elides maintainability... I would not want to have to debug a generic sorter written in c preprocessor.
- flohofwoe 4y agoIn the case of qsort() at least, there wouldn't be "preprocessor generics" involved, because the comparison is done in a user-provided callback function. But both the comparison function and the qsort implementation must be visible to the compiler (or in case of LTO: the linker) for the "auto-specialization" (via the optimizer) to kick in. It's a bit brittle of course to depend too much on the optimizer, but the whole idea of "zero cost abstraction" in C++ also puts a lot of trust into the optimizer passes.
- randbox 4y agoThe only preprocessor code required for writing 'static inline' header functions is "#pragma once". Inline functions look like normal functions.