What is the C ++ equivalent for C #
I am trying to avoid managed managed C ++ (CLI) overflow. There is an unchecked keyword in C #, and C ++ overflow doesn't end in exceptions.
For reference, unchecked is documented here . Basically if you do this:
unchecked
{
int1 = 2147483647 + 10; //this overflows in CLI but is ok in C# and C++
}
In C # it will not overflow, but rather converts to int by taking the least significant bits. This is useful if, for example, you are calculating hash codes.
Note. I realize there is no equivalent C ++ keyword, but some bit shifting should do the trick;
+3
source to share