tmp/tmp4er4388x/{from.md → to.md}
RENAMED
|
@@ -1,21 +1,22 @@
|
|
| 1 |
### Subscripting <a id="over.sub">[[over.sub]]</a>
|
| 2 |
|
| 3 |
-
`operator[]`
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
implements the subscripting syntax
|
| 7 |
|
| 8 |
``` bnf
|
| 9 |
postfix-expression '[' expr-or-braced-init-list ']'
|
| 10 |
```
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
[*Example 1*:
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
struct X {
|
|
|
|
| 1 |
### Subscripting <a id="over.sub">[[over.sub]]</a>
|
| 2 |
|
| 3 |
+
A *subscripting operator function* is a function named `operator[]` that
|
| 4 |
+
is a non-static member function with exactly one parameter. For an
|
| 5 |
+
expression of the form
|
|
|
|
| 6 |
|
| 7 |
``` bnf
|
| 8 |
postfix-expression '[' expr-or-braced-init-list ']'
|
| 9 |
```
|
| 10 |
|
| 11 |
+
the operator function is selected by overload resolution
|
| 12 |
+
[[over.match.oper]]. If a member function is selected, the expression is
|
| 13 |
+
interpreted as
|
| 14 |
+
|
| 15 |
+
``` bnf
|
| 16 |
+
postfix-expression . operator '['']' '(' expr-or-braced-init-list ')'
|
| 17 |
+
```
|
| 18 |
|
| 19 |
[*Example 1*:
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
struct X {
|