tmp/tmpm828e3oe/{from.md → to.md}
RENAMED
|
@@ -1,15 +1,12 @@
|
|
| 1 |
## Local class declarations <a id="class.local">[[class.local]]</a>
|
| 2 |
|
| 3 |
A class can be declared within a function definition; such a class is
|
| 4 |
-
called a *local class*.
|
| 5 |
-
enclosing scope. The local class is in the scope of the enclosing scope,
|
| 6 |
-
and has the same access to names outside the function as does the
|
| 7 |
-
enclosing function.
|
| 8 |
|
| 9 |
[*Note 1*: A declaration in a local class cannot odr-use
|
| 10 |
-
[[
|
| 11 |
|
| 12 |
[*Example 1*:
|
| 13 |
|
| 14 |
``` cpp
|
| 15 |
int x;
|
|
@@ -24,17 +21,17 @@ void f() {
|
|
| 24 |
struct local {
|
| 25 |
int g() { return x; } // error: odr-use of non-odr-usable variable x
|
| 26 |
int h() { return s; } // OK
|
| 27 |
int k() { return ::x; } // OK
|
| 28 |
int l() { return q(); } // OK
|
| 29 |
-
int m() { return N; } // OK
|
| 30 |
int* n() { return &N; } // error: odr-use of non-odr-usable variable N
|
| 31 |
int p() { return y; } // error: odr-use of non-odr-usable structured binding y
|
| 32 |
};
|
| 33 |
}
|
| 34 |
|
| 35 |
-
local* p = 0; // error: local not
|
| 36 |
```
|
| 37 |
|
| 38 |
— *end example*]
|
| 39 |
|
| 40 |
An enclosing function has no special access to members of the local
|
|
|
|
| 1 |
## Local class declarations <a id="class.local">[[class.local]]</a>
|
| 2 |
|
| 3 |
A class can be declared within a function definition; such a class is
|
| 4 |
+
called a *local class*.
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
[*Note 1*: A declaration in a local class cannot odr-use
|
| 7 |
+
[[term.odr.use]] a local entity from an enclosing scope. — *end note*]
|
| 8 |
|
| 9 |
[*Example 1*:
|
| 10 |
|
| 11 |
``` cpp
|
| 12 |
int x;
|
|
|
|
| 21 |
struct local {
|
| 22 |
int g() { return x; } // error: odr-use of non-odr-usable variable x
|
| 23 |
int h() { return s; } // OK
|
| 24 |
int k() { return ::x; } // OK
|
| 25 |
int l() { return q(); } // OK
|
| 26 |
+
int m() { return N; } // OK, not an odr-use
|
| 27 |
int* n() { return &N; } // error: odr-use of non-odr-usable variable N
|
| 28 |
int p() { return y; } // error: odr-use of non-odr-usable structured binding y
|
| 29 |
};
|
| 30 |
}
|
| 31 |
|
| 32 |
+
local* p = 0; // error: local not found
|
| 33 |
```
|
| 34 |
|
| 35 |
— *end example*]
|
| 36 |
|
| 37 |
An enclosing function has no special access to members of the local
|