4 ms·
In C++, << has higher precedence than &&, so in effect what is being done is (cout << 1) && 2; ...which is not an error, since the result of operator<< is
by pbsd 13y ago
In C++, << has higher precedence than &&, so in effect what is being done is
(cout << 1) && 2;
...which is not an error, since the result of operator<< is an std::ostream, which is convertible to bool. Therefore operator&&(bool, bool) is invoked but the result is, of course, discarded.
Disambiguating the expression with parentheses should output 1 in every case.
- chewxy 13y agoI wrote the article (didn't plan on HN traffic, thanks Boyter). I've fixed it with your comment. Thanks