Every programmer should know that:


( Morgan Laws)
In some cases, in order to optimize the program, it may happen that the compiler changes (!p && !q) to (!(p || q)) .
The two expressions are equivalent, and there is no difference in evaluating the first or second.
But in C ++, you can overload operators, and an overloaded operator may not always respect this property. Thus, transforming the code in this way will actually change the code.
Should the compiler use De Morgan's laws when ! , || and && overloaded?
c ++ compiler-optimization language-lawyer operator-overloading
Alex Oct. 14 '15 at 8:36 2015-10-14 08:36
source share