Hmm. Don’t fancy adding an operation to that function, as it’s supposed to be as quick as possible, and compilers might fail to optimise it out. How about just
it won’t work as it assert because you’re loosing information while not stating it explicitly.
They say that this what the compiler will do anyway so…
just enable smaller type check to see the message.
The problem I think is that you need to explicitly say that you don’t care
about the upper byte of the int16 which you are going to lose with the shift.
I wouldn’t - it’s one of the lamest-sounding bits of slang that’s appeared in recent years! When I hear it I find myself hanging there, waiting for the rest of the sentence… “your bad… what??”
That’s pretty useless of the checker if it can’t even tell that you’re deliberately truncating it. What about using a static_cast<>?
yes, good point! And the 64-bit version can use that too, of course… I don’t know why I implemented the 32-bit swap like that and forgot to do the others!