• :: ^a798ff
    • scope operator「resolver 域的解析符」, used to access names in a namespace
    • when it has an empty left-hand side, it is a request to fetch the name on the right-hand side from the global scope.

Arithmetic

  • left associative
  • yield rvalue
  • the operands to % must have integral type

Logical and Relational

  • require and yield rvalue.

Assignment

  • right associative and yield left-hand operand as lvalue. (可以使用连等号,但注意规矩,连起来的要么相同,要么可转化)
  • if the right-hand operand is a braced initializer list (a curly brace) and it contain at most one value, that value doesn’t allowed a narrowing conversion.

Increment and Decrement

  • 符号在前,先加的值;符号在后,先值再加。
int i = 0, j;
j = ++i;  // j=1, i=1
j = i++;  // j=1, i=2
  • prefix version yields lvalue, postfix version yields rvalue.
  • Better to Use Prefix Version. code-style 因为后缀版会有一个保存原值的行为,而当使用复杂的iterator时,这个开销是很大的

Conditional

cond ? expr1 : expr2

  • guarantees only one of the expr is evaluated.
  • result lvalue if the expr is lvalue.
  • 优先级可低了,通常都是跟括号一起出现的

Bitwise

  • take operands of integral type
  • As usual, “small integer” will first promoted
  • operands can be either signed or unsigned, but the way to handle “sign bit” is machine dependent. So, better use unsigned type

sizeof

  • result is a constant expression (编译时就决定了的值), type of size_t. (也因此可以用做定义数组的维数)
  • doesn’t evaluate its operand
  • doesn’t convert the array to a pointer

Comma

  • guarantee the Order of Evaluate: left to right
  • 左侧表达式的结果被舍掉了,result是右侧表达式。whether lvalue depand on the r-h operand.