

 This page uses content from Wikipedia. The original article was at Operators in C and C++. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)



Task

Provide a list of   precedence   and   associativity   of all the operators and constructs that the language utilizes in descending order of precedence such that an operator which is listed on some row will be evaluated prior to any operator that is listed on a row further below it.

Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same level of precedence, in the given direction.

State whether arguments are passed by value or by reference.




        (expr)                          # grouping
        {expr1;expr2;...}               # compound
        x(expr1,expr2,...)              # process argument list
        x{expr1,expr2,...}              # process co-expression list
        [expr1,expr2,...]               # list
        expr.F                          # field reference
        expr1[expr2]                    # subscript
        expr1[expr2,expr3,...]          # multiple subscript
        expr1[expr2:expr3]              # section
        expr1[expr2+:expr3]             # section
        expr1[expr2-:expr3]             # section

        not expr                        # success/failure reversal
        | expr                          # repeated alternation
        ! expr                          # element generation
        * expr                          # size
        + expr                          # numeric value
        - expr                          # negative
        . expr                          # value (dereference)
        / expr                          # null
        \ expr                          # non-null
        = expr                          # match and tab
        ? expr                          # random value
        ~ expr                          # cset complement
        @ expr                          # activation
        ^ expr                          # refresh

        expr1 \ expr2                   # limitation
        expr1 @ expr2                   # transmission
        expr1 ! expr2                   # invocation

        expr1 ^ expr2                   # power

        expr1 * expr2                   # product
        expr1 / expr2                   # quotient
        expr1 % expr2                   # remainder
        expr1 ** expr2                  # intersection

        expr1 + expr2                   # sum
        expr1 - expr2                   # numeric difference
        expr1 ++ expr2                  # union
        expr1 -- expr2                  # cset or set difference

        expr1 || expr2                  # string concatenation
        expr1 ||| expr2                 # list concatenation

        expr1 < expr2                   # numeric comparison
        expr1 <= expr2                  # numeric comparison
        expr1 = expr2                   # numeric comparison
        expr1 >= expr2                  # numeric comparison
        expr1 > expr2                   # numeric comparison
        expr1 ~= expr2                  # numeric comparison
        expr1 << expr2                  # string comparison
        expr1 <<= expr2                 # string comparison
        expr1 == expr2                  # string comparison
        expr1 >>= expr2                 # string comparison
        expr1 >> expr2                  # string comparison
        expr1 ~== expr2                 # string comparison
        expr1 === expr2                 # value comparison
        expr1 ~=== expr2                # value comparison

        expr1 | expr2                   # alternation

        expr1 to expr2 by expr3         # integer generation

        expr1 := expr2                  # assignment
        expr1 <- expr2                  # reversible assignment
        expr1 :=: expr2                 # exchange
        expr1 <-> expr2                 # reversible exchange
        expr1 op:= expr2                # (augmented assignments)

        expr1 ? expr2                   # string scanning

        expr1 & expr2                   # conjunction

Low Precedence Expressions

        break [expr]                    # break from loop
        case expr0 of {                 # case selection
           expr1:expr2
           ...
           [default:exprn]
           }
        create expr                     # co-expression creation
        every expr1 [do expr2]          # iterate over generated values
        fail                            # failure of procedure
        if expr1 then exp2 [else exp3]  # if-then-else
        next                            # go to top of loop
        repeat expr                     # loop
        return expr                     # return from procedure
        suspend expr1 [do expr2]        # suspension of procedure
        until expr1 [do expr2]          # until-loop
        while expr1 [do expr2]          # while-loop
