File: evaluation.yo

package info (click to toggle)
c%2B%2B-annotations 12.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,044 kB
  • sloc: cpp: 24,337; makefile: 1,517; ansic: 165; sh: 121; perl: 90
file content (24 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    Traditionally, the evaluation order of expressions of operands of binary
operators is, except for the boolean operators tt(and) and tt(or), not
defined. C++ changed this for postfix expressions, assignment expressions
(including compound assignments), and shift operators:
    itemization(
    it() Expressions using postfix operators (like index operators and member
        selectors) are evaluated from left to right (do not confuse this with
        postfix increment or decrement operators, which cannot be concatenated
        (e.g., tt(variable++++) does not compile)).
    it() Assignment expressions are evaluated from right to left;
    it() Operands of shift operators are evaluated from left to right.
    )

    In the following examples tt(first) is evaluated before tt(second), before
tt(third), before tt(fourth), whether they are single variables, parenthesized
expressions, or function calls:
        verb(    first.second
    fourth += third = second += first
    first << second << third << fourth
    first >> second >> third >> fourth)

In addition, when overloading an operator, the function implementing the
overloaded operator is evaluated like the built-in operator it overloads, and
not in the way function calls are generally ordered.