For a prime integer, as others have explained, it 0 == iminimizes the risk of creating a typo.
However, if you have overloaded operator==, then it 0 == imay be a mistake:
class X
{
public:
X(int x) : _x(x) {};
bool operator==(int y) { return _x == y; }
private:
int _x;
};
....
X x(0);
if (x == 0)
;
if (0 == x)
;
Alexd source
share