3 ms·
Two points. 1) Currently, the code could be written with normal overloading (one for int and one for unsigned). No traits required. 2) The current code relies o
by Jaxan 7y ago
Two points. 1) Currently, the code could be written with normal overloading (one for int and one for unsigned). No traits required. 2) The current code relies on an implicit cast to int or unsigned int. I’m not sure that’s good.
- edflsafoiewq 7y ago> Currently, the code could be written with normal overloading (one for int and one for unsigned). No traits required f( (uint8_t)0 ) will dispatch to the overload f(int) with overloads. The type-trait code will dispatch to f_unsigned(unsigned).
- dirtydroog 7y agoI didn't believe you but you're right. The uint8_t gets promoted to int, not unsigned int. https://godbolt.org/z/icQHw3 https://godbolt.org/z/icQHw3
- saagarjha 7y agoC’s integer promotion rules aren’t the best.