[expr.sub] (original) (raw)

7 Expressions [expr]

7.6 Compound expressions [expr.compound]

7.6.1 Postfix expressions [expr.post]

7.6.1.2 Subscripting [expr.sub]

A subscript expression is a postfix expression followed by square brackets containing a possibly empty, comma-separated list of initializer-clause_s_that constitute the arguments to the subscript operator.

The initialization of a non-object parameter of a subscript operator function S, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other non-object parameter of S.

One of the expressions shall be a glvalue of type “array ofT” or a prvalue of type “pointer to T” and the other shall be a prvalue of unscoped enumeration or integral type.

The result is of type “T”.

The type “T” shall be a completely-defined object type.48

The expression E1[E2] is identical (by definition) to*((E1)+(E2)), except that in the case of an array operand, the result is an lvalue if that operand is an lvalue and an xvalue otherwise.

[Note 1:

Despite its asymmetric appearance, subscripting is a commutative operation except for sequencing.

— _end note_]