6 ms·
Even if you named the functions differently (clz8/16/32/64), you still needed to match them to the appropriate __builtin_clz version.
by foonathan 11y ago
Even if you named the functions differently (clz8/16/32/64), you still needed to match them to the appropriate __builtin_clz version.
- jstimpfle 11y agoThe matching itself is not a problem. Arguably it's required for portability, but it's very straightforward. Obvious implementation, all in one place, practically no maintenance cost, very unlikely to break. But think about all the callers of these functions. There are usually more callers, at disparate places, and context will be less narrow there. It's important not to conceal what is intended to happen at the call side. If these functions are overloaded and at some point due to unexpected integer promotion or a crazy typedef the wrong overload is picked, you will have a hard time debugging.
- foonathan 11y agoAnd I've showed one way to do the matching in an automated way. How you wrap those implementation things, is up to you. I agree, overloading might have problems.