Closed nyanpasu64 closed 4 years ago
You could probably do this. Use std::is_signed<T>::value
to determine if T
is signed. You can use that in operator T()
and, if it's signed, sign-extend the most significant bit. Here are a few possible ways to do that: https://stackoverflow.com/questions/5814072/sign-extend-a-nine-bit-number-in-c
If you have a 64-bit bitfield, is it possible to mark certain fields as signed, for example by passing in a custom return type of int16_t?