tmp/tmpl646uzhw/{from.md → to.md}
RENAMED
|
@@ -4,18 +4,21 @@ In a declaration `T` `D` where `D` has the form
|
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
'*' attribute-specifier-seqₒₚₜ cv-qualifier-seqₒₚₜ 'D1'
|
| 7 |
```
|
| 8 |
|
| 9 |
-
and the type of the identifier in the declaration `T` `D1` is
|
| 10 |
-
then the type of the identifier of
|
| 11 |
-
*cv-qualifier*
|
| 12 |
-
|
|
|
|
| 13 |
[[dcl.attr.grammar]]) appertains to the pointer and not to the object
|
| 14 |
pointed to.
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
const int ci = 10, *pc = &ci, *const cpc = pc, **ppc;
|
| 20 |
int i, *p, *const cp = &i;
|
| 21 |
```
|
|
@@ -52,18 +55,19 @@ ppc = &p; // error
|
|
| 52 |
Each is unacceptable because it would either change the value of an
|
| 53 |
object declared `const` or allow it to be changed through a
|
| 54 |
cv-unqualified pointer later, for example:
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
-
*ppc = &ci; // OK, but would make p point to ci
|
| 58 |
-
// ... because of previous error
|
| 59 |
*p = 5; // clobber ci
|
| 60 |
```
|
| 61 |
|
|
|
|
|
|
|
| 62 |
See also [[expr.ass]] and [[dcl.init]].
|
| 63 |
|
| 64 |
-
Forming a pointer to reference type is ill-formed; see
|
| 65 |
-
Forming a
|
| 66 |
-
has *cv-qualifier*s or a *ref-qualifier*; see
|
| 67 |
-
address of a bit-field ([[class.bit]]) cannot be
|
| 68 |
-
never point to a bit-field.
|
| 69 |
|
|
|
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
'*' attribute-specifier-seqₒₚₜ cv-qualifier-seqₒₚₜ 'D1'
|
| 7 |
```
|
| 8 |
|
| 9 |
+
and the type of the identifier in the declaration `T` `D1` is
|
| 10 |
+
“*derived-declarator-type-list* `T`”, then the type of the identifier of
|
| 11 |
+
`D` is “*derived-declarator-type-list* *cv-qualifier-seq* pointer to
|
| 12 |
+
`T`”. The *cv-qualifier*s apply to the pointer and not to the object
|
| 13 |
+
pointed to. Similarly, the optional *attribute-specifier-seq* (
|
| 14 |
[[dcl.attr.grammar]]) appertains to the pointer and not to the object
|
| 15 |
pointed to.
|
| 16 |
|
| 17 |
+
[*Example 1*:
|
| 18 |
+
|
| 19 |
+
The declarations
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
const int ci = 10, *pc = &ci, *const cpc = pc, **ppc;
|
| 23 |
int i, *p, *const cp = &i;
|
| 24 |
```
|
|
|
|
| 55 |
Each is unacceptable because it would either change the value of an
|
| 56 |
object declared `const` or allow it to be changed through a
|
| 57 |
cv-unqualified pointer later, for example:
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
+
*ppc = &ci; // OK, but would make p point to ci because of previous error
|
|
|
|
| 61 |
*p = 5; // clobber ci
|
| 62 |
```
|
| 63 |
|
| 64 |
+
— *end example*]
|
| 65 |
+
|
| 66 |
See also [[expr.ass]] and [[dcl.init]].
|
| 67 |
|
| 68 |
+
[*Note 1*: Forming a pointer to reference type is ill-formed; see
|
| 69 |
+
[[dcl.ref]]. Forming a function pointer type is ill-formed if the
|
| 70 |
+
function type has *cv-qualifier*s or a *ref-qualifier*; see
|
| 71 |
+
[[dcl.fct]]. Since the address of a bit-field ([[class.bit]]) cannot be
|
| 72 |
+
taken, a pointer can never point to a bit-field. — *end note*]
|
| 73 |
|