File tree Expand file tree Collapse file tree 2 files changed +12
-30
lines changed Expand file tree Collapse file tree 2 files changed +12
-30
lines changed Original file line number Diff line number Diff line change 1183
1183
1184
1184
\pnum
1185
1185
\begin {note }
1186
- Except where it has been declared for a class\iref {over.sub },
1187
- the subscript operator
1188
- \tcode {[]}
1189
- is interpreted
1190
- in such a way that
1191
- \tcode {E1[E2]}
1192
- is identical to
1193
- \tcode {*((E1)+(E2))}\iref {expr.sub }.
1194
- Because of the conversion rules
1195
- that apply to
1196
- \tcode {+},
1197
- if
1198
- \tcode {E1}
1199
- is an array and
1200
- \tcode {E2}
1201
- an integer,
1202
- then
1203
- \tcode {E1[E2]}
1204
- refers to the
1205
- \tcode {E2}-th
1206
- member of
1207
- \tcode {E1}.
1208
- Therefore,
1209
- despite its asymmetric
1210
- appearance, subscripting is a commutative operation.
1186
+ The subscript operator can be overloaded for a class\iref {over.sub }.
1187
+ For the operator's built-in meaning, see \ref {expr.sub }.
1211
1188
\end {note }
1212
1189
1213
1190
\rSec 2[dcl.fct]{Functions}%
Original file line number Diff line number Diff line change 2145
2145
is true even if the subscript operator is used in the following common idiom:
2146
2146
\tcode {\& x[0]}.}
2147
2147
The expression \tcode {E1[E2]} is identical (by definition) to
2148
- \tcode {*((E1)+(E2))}
2149
- \begin {note }
2150
- see~\ref {expr.unary } and~\ref {expr.add } for details of \tcode {*} and
2151
- \tcode {+} and~\ref {dcl.array } for details of arrays.
2152
- \end {note }, except that in the case of an array operand, the result is an lvalue
2148
+ \tcode {*((E1)+(E2))},
2149
+ except that in the case of an array operand, the result is an lvalue
2153
2150
if that operand is an lvalue and an xvalue otherwise.
2154
2151
The expression \tcode {E1} is sequenced before the expression \tcode {E2}.
2155
2152
2153
+ \pnum
2154
+ \begin {note }
2155
+ Despite its asymmetric appearance, subscripting is a commutative
2156
+ operation except for sequencing.
2157
+ See~\ref {expr.unary } and~\ref {expr.add } for details of \tcode {*} and
2158
+ \tcode {+} and~\ref {dcl.array } for details of array types.
2159
+ \end {note }
2160
+
2156
2161
\pnum
2157
2162
A \grammarterm {braced-init-list} shall not be used with the built-in subscript operator.
2158
2163
You can’t perform that action at this time.
0 commit comments