tmp/tmpt0q4wpiy/{from.md → to.md}
RENAMED
|
@@ -9,13 +9,13 @@ In a declaration `T` `D` where `D` has either of the forms
|
|
| 9 |
|
| 10 |
and the type of the identifier in the declaration `T` `D1` is “ `T`,”
|
| 11 |
then the type of the identifier of `D` is “ reference to `T`.” The
|
| 12 |
optional *attribute-specifier-seq* appertains to the reference type.
|
| 13 |
Cv-qualified references are ill-formed except when the cv-qualifiers are
|
| 14 |
-
introduced through the use of a typedef
|
| 15 |
-
|
| 16 |
-
are ignored.
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
typedef int& A;
|
| 20 |
const A aref = 3; // ill-formed; lvalue reference to non-const initialized with rvalue
|
| 21 |
```
|
|
@@ -85,20 +85,20 @@ contains an explicit `extern` specifier ([[dcl.stc]]), is a class
|
|
| 85 |
member ([[class.mem]]) declaration within a class definition, or is the
|
| 86 |
declaration of a parameter or a return type ([[dcl.fct]]); see
|
| 87 |
[[basic.def]]. A reference shall be initialized to refer to a valid
|
| 88 |
object or function. in particular, a null reference cannot exist in a
|
| 89 |
well-defined program, because the only way to create such a reference
|
| 90 |
-
would be to bind it to the “object” obtained by
|
| 91 |
-
pointer, which causes undefined behavior. As described in
|
| 92 |
[[class.bit]], a reference cannot be bound directly to a bit-field.
|
| 93 |
|
| 94 |
-
If a typedef ([[dcl.typedef]]
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
|
| 101 |
``` cpp
|
| 102 |
int i;
|
| 103 |
typedef int& LRI;
|
| 104 |
typedef int&& RRI;
|
|
@@ -112,5 +112,8 @@ RRI&& r5 = 5; // r5 has the type int&&
|
|
| 112 |
|
| 113 |
decltype(r2)& r6 = i; // r6 has the type int&
|
| 114 |
decltype(r2)&& r7 = i; // r7 has the type int&
|
| 115 |
```
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
and the type of the identifier in the declaration `T` `D1` is “ `T`,”
|
| 11 |
then the type of the identifier of `D` is “ reference to `T`.” The
|
| 12 |
optional *attribute-specifier-seq* appertains to the reference type.
|
| 13 |
Cv-qualified references are ill-formed except when the cv-qualifiers are
|
| 14 |
+
introduced through the use of a *typedef-name* ([[dcl.typedef]],
|
| 15 |
+
[[temp.param]]) or *decltype-specifier* ([[dcl.type.simple]]), in which
|
| 16 |
+
case the cv-qualifiers are ignored.
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
typedef int& A;
|
| 20 |
const A aref = 3; // ill-formed; lvalue reference to non-const initialized with rvalue
|
| 21 |
```
|
|
|
|
| 85 |
member ([[class.mem]]) declaration within a class definition, or is the
|
| 86 |
declaration of a parameter or a return type ([[dcl.fct]]); see
|
| 87 |
[[basic.def]]. A reference shall be initialized to refer to a valid
|
| 88 |
object or function. in particular, a null reference cannot exist in a
|
| 89 |
well-defined program, because the only way to create such a reference
|
| 90 |
+
would be to bind it to the “object” obtained by indirection through a
|
| 91 |
+
null pointer, which causes undefined behavior. As described in
|
| 92 |
[[class.bit]], a reference cannot be bound directly to a bit-field.
|
| 93 |
|
| 94 |
+
If a *typedef-name* ([[dcl.typedef]], [[temp.param]]) or a
|
| 95 |
+
*decltype-specifier* ([[dcl.type.simple]]) denotes a type `TR` that is
|
| 96 |
+
a reference to a type `T`, an attempt to create the type “lvalue
|
| 97 |
+
reference to cv `TR`” creates the type “lvalue reference to `T`”, while
|
| 98 |
+
an attempt to create the type “rvalue reference to cv `TR`” creates the
|
| 99 |
+
type `TR`.
|
| 100 |
|
| 101 |
``` cpp
|
| 102 |
int i;
|
| 103 |
typedef int& LRI;
|
| 104 |
typedef int&& RRI;
|
|
|
|
| 112 |
|
| 113 |
decltype(r2)& r6 = i; // r6 has the type int&
|
| 114 |
decltype(r2)&& r7 = i; // r7 has the type int&
|
| 115 |
```
|
| 116 |
|
| 117 |
+
Forming a reference to function type is ill-formed if the function type
|
| 118 |
+
has *cv-qualifier*s or a *ref-qualifier*; see [[dcl.fct]].
|
| 119 |
+
|