order of evaluation of function parameters

From the C++ standard: The order of evaluation of arguments is unspecified. All side effects of argument expression evaluations take effect before the function is entered. The order of evaluation of the postfix expression and the argument expression list is unspecified. However, your example would only have undefined behavior if the arguments were x>>=2 and … Read more

Precedence: Logical or vs. Ternary operator

Yes, the || operator has higher precedence than the conditional ?: operator. This means that it is executed first. From the page you link: Operator precedence determines the order in which operators are evaluated. Operators with higher precedence are evaluated first. Let’s have a look at all the operations here: step = step || (start … Read more

The output of cout

It’s all about Operator Precedence. The Overloaded Bitwise Left Shift Operator operator<<(std::basic_ostream) has a higher priority than the Logical AND Operator &&. #include <iostream> int main() { std::cout << (1 && 0); return 0; } If you are not 146% sure about the priority of an operator, do not hesitate to use brackets. Most modern … Read more

Haskell operator vs function precedence

Firstly, application (whitespace) is the highest precedence “operator”. Secondly, in Haskell, there’s really no distinction between operators and functions, other than that operators are infix by default, while functions aren’t. You can convert functions to infix with backticks 2 `f` x and convert operators to prefix with parens: (+) 2 3 So, your question is … Read more