In StarCitizen Bugsmashers about tick rates a code snippet like this is visible:
uint i = someBool ? someuint : uint(-1);
// ... some other code ...
if (i == uint(-1)) { /* do something */ }
In case someBool
is false, then i = 4294967295
which is 0xFFFFFFFF
/the maximum 32bit uint value:
#include <iostream>
int main()
{
const auto i = uint(-1);
if (i == uint(-1))
{
std::cout << i;
}
}
I assume, the motivation for doing this is to avoid having to use another control variable for the if statement. Is the construction of uint(-1)
defined behaviour? If yes, why?