From Jason Turner

[dcl.ref]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpt0q4wpiy/{from.md → to.md} +14 -11
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 ([[dcl.typedef]]) or of a
15
- template type argument ([[temp.arg]]), in which case the cv-qualifiers
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 dereferencing a null
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]]), a type *template-parameter* (
95
- [[temp.arg.type]]), or a *decltype-specifier* ([[dcl.type.simple]])
96
- denotes a type `TR` that is a reference to a type `T`, an attempt to
97
- create the type “lvalue reference to cv `TR`” creates the type “lvalue
98
- reference to `T`”, while an attempt to create the type “rvalue reference
99
- to cv `TR`” creates the type `TR`.
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
+