tmp/tmp27mbv8in/{from.md → to.md}
RENAMED
|
@@ -99,12 +99,12 @@ conversion sequences unless one of the following rules applies:
|
|
| 99 |
```
|
| 100 |
|
| 101 |
— *end example*]
|
| 102 |
or, if not that,
|
| 103 |
- `S1` and `S2` include reference bindings [[dcl.init.ref]] and `S1`
|
| 104 |
-
binds an lvalue reference to
|
| 105 |
-
rvalue reference to
|
| 106 |
\[*Example 4*:
|
| 107 |
``` cpp
|
| 108 |
int f(void(&)()); // #1
|
| 109 |
int f(void(&&)()); // #2
|
| 110 |
void g();
|
|
@@ -112,28 +112,33 @@ conversion sequences unless one of the following rules applies:
|
|
| 112 |
```
|
| 113 |
|
| 114 |
— *end example*]
|
| 115 |
or, if not that,
|
| 116 |
- `S1` and `S2` differ only in their qualification conversion
|
| 117 |
-
[[conv.qual]] and yield similar types `T1` and `T2`, respectively
|
| 118 |
-
where
|
|
|
|
|
|
|
|
|
|
| 119 |
\[*Example 5*:
|
| 120 |
``` cpp
|
| 121 |
int f(const volatile int *);
|
| 122 |
int f(const int *);
|
| 123 |
int i;
|
| 124 |
int j = f(&i); // calls f(const int*)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
```
|
| 126 |
|
| 127 |
— *end example*]
|
| 128 |
or, if not that,
|
| 129 |
- `S1`
|
| 130 |
-
and `S2`
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
`S2` refers is more cv-qualified than the type to which the
|
| 134 |
-
reference initialized by `S1` refers.
|
| 135 |
\[*Example 6*:
|
| 136 |
``` cpp
|
| 137 |
int f(const int &);
|
| 138 |
int f(int &);
|
| 139 |
int g(const int &);
|
|
@@ -149,20 +154,51 @@ conversion sequences unless one of the following rules applies:
|
|
| 149 |
};
|
| 150 |
void g(const X& a, X b) {
|
| 151 |
a.f(); // calls X::f() const
|
| 152 |
b.f(); // calls X::f()
|
| 153 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
```
|
| 155 |
|
| 156 |
— *end example*]
|
| 157 |
- User-defined conversion sequence `U1` is a better conversion sequence
|
| 158 |
than another user-defined conversion sequence `U2` if they contain the
|
| 159 |
same user-defined conversion function or constructor or they
|
| 160 |
initialize the same class in an aggregate initialization and in either
|
| 161 |
case the second standard conversion sequence of `U1` is better than
|
| 162 |
the second standard conversion sequence of `U2`.
|
| 163 |
-
\[*Example
|
| 164 |
``` cpp
|
| 165 |
struct A {
|
| 166 |
operator short();
|
| 167 |
} a;
|
| 168 |
int f(int);
|
|
@@ -190,11 +226,11 @@ indistinguishable unless one of the following rules applies:
|
|
| 190 |
to the rank of `FP2`, and
|
| 191 |
- `T3` is not a floating-point type, or `T3` is a floating-point type
|
| 192 |
whose rank is not equal to the rank of `FP1`, or the floating-point
|
| 193 |
conversion subrank [[conv.rank]] of `FP2` is greater than the
|
| 194 |
subrank of `T3`.
|
| 195 |
-
\[*Example
|
| 196 |
``` cpp
|
| 197 |
int f(std::float32_t);
|
| 198 |
int f(std::float64_t);
|
| 199 |
int f(long long);
|
| 200 |
float x;
|
|
@@ -211,11 +247,11 @@ indistinguishable unless one of the following rules applies:
|
|
| 211 |
of `B*` to `void*`.
|
| 212 |
- If class `B` is derived directly or indirectly from class `A` and
|
| 213 |
class `C` is derived directly or indirectly from `B`,
|
| 214 |
- conversion of `C*` to `B*` is better than conversion of `C*` to
|
| 215 |
`A*`,
|
| 216 |
-
\[*Example
|
| 217 |
``` cpp
|
| 218 |
struct A {};
|
| 219 |
struct B : public A {};
|
| 220 |
struct C : public B {};
|
| 221 |
C* pc;
|
|
|
|
| 99 |
```
|
| 100 |
|
| 101 |
— *end example*]
|
| 102 |
or, if not that,
|
| 103 |
- `S1` and `S2` include reference bindings [[dcl.init.ref]] and `S1`
|
| 104 |
+
binds an lvalue reference to an lvalue of function type and `S2`
|
| 105 |
+
binds an rvalue reference to an lvalue of function type
|
| 106 |
\[*Example 4*:
|
| 107 |
``` cpp
|
| 108 |
int f(void(&)()); // #1
|
| 109 |
int f(void(&&)()); // #2
|
| 110 |
void g();
|
|
|
|
| 112 |
```
|
| 113 |
|
| 114 |
— *end example*]
|
| 115 |
or, if not that,
|
| 116 |
- `S1` and `S2` differ only in their qualification conversion
|
| 117 |
+
[[conv.qual]] and yield similar types `T1` and `T2`, respectively
|
| 118 |
+
(where a standard conversion sequence that is a reference binding is
|
| 119 |
+
considered to yield the cv-unqualified referenced type), where `T1`
|
| 120 |
+
and `T2` are not the same type, and `const T2` is
|
| 121 |
+
reference-compatible with `T1` [[dcl.init.ref]]
|
| 122 |
\[*Example 5*:
|
| 123 |
``` cpp
|
| 124 |
int f(const volatile int *);
|
| 125 |
int f(const int *);
|
| 126 |
int i;
|
| 127 |
int j = f(&i); // calls f(const int*)
|
| 128 |
+
int g(const int*);
|
| 129 |
+
int g(const volatile int* const&);
|
| 130 |
+
int* p;
|
| 131 |
+
int k = g(p); // calls g(const int*)
|
| 132 |
```
|
| 133 |
|
| 134 |
— *end example*]
|
| 135 |
or, if not that,
|
| 136 |
- `S1`
|
| 137 |
+
and `S2` bind “reference to `T1`” and “reference to `T2`”,
|
| 138 |
+
respectively [[dcl.init.ref]], where `T1` and `T2` are not the same
|
| 139 |
+
type, and `T2` is reference-compatible with `T1`
|
|
|
|
|
|
|
| 140 |
\[*Example 6*:
|
| 141 |
``` cpp
|
| 142 |
int f(const int &);
|
| 143 |
int f(int &);
|
| 144 |
int g(const int &);
|
|
|
|
| 154 |
};
|
| 155 |
void g(const X& a, X b) {
|
| 156 |
a.f(); // calls X::f() const
|
| 157 |
b.f(); // calls X::f()
|
| 158 |
}
|
| 159 |
+
|
| 160 |
+
int h(int (&)[]);
|
| 161 |
+
int h(int (&)[1]);
|
| 162 |
+
void g2() {
|
| 163 |
+
int a[1];
|
| 164 |
+
h(a); // calls h(int (&)[1])
|
| 165 |
+
}
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
— *end example*]
|
| 169 |
+
or, if not that,
|
| 170 |
+
- `S1` and `S2` bind the same reference type “reference to `T`” and
|
| 171 |
+
have source types `V1` and `V2`, respectively, where the standard
|
| 172 |
+
conversion sequence from `V1*` to `T*` is better than the standard
|
| 173 |
+
conversion sequence from `V2*` to `T*`.
|
| 174 |
+
\[*Example 7*:
|
| 175 |
+
``` cpp
|
| 176 |
+
struct Z {};
|
| 177 |
+
|
| 178 |
+
struct A {
|
| 179 |
+
operator Z&();
|
| 180 |
+
operator const Z&(); // #1
|
| 181 |
+
};
|
| 182 |
+
|
| 183 |
+
struct B {
|
| 184 |
+
operator Z();
|
| 185 |
+
operator const Z&&(); // #2
|
| 186 |
+
};
|
| 187 |
+
|
| 188 |
+
const Z& r1 = A(); // OK, uses #1
|
| 189 |
+
const Z&& r2 = B(); // OK, uses #2
|
| 190 |
```
|
| 191 |
|
| 192 |
— *end example*]
|
| 193 |
- User-defined conversion sequence `U1` is a better conversion sequence
|
| 194 |
than another user-defined conversion sequence `U2` if they contain the
|
| 195 |
same user-defined conversion function or constructor or they
|
| 196 |
initialize the same class in an aggregate initialization and in either
|
| 197 |
case the second standard conversion sequence of `U1` is better than
|
| 198 |
the second standard conversion sequence of `U2`.
|
| 199 |
+
\[*Example 8*:
|
| 200 |
``` cpp
|
| 201 |
struct A {
|
| 202 |
operator short();
|
| 203 |
} a;
|
| 204 |
int f(int);
|
|
|
|
| 226 |
to the rank of `FP2`, and
|
| 227 |
- `T3` is not a floating-point type, or `T3` is a floating-point type
|
| 228 |
whose rank is not equal to the rank of `FP1`, or the floating-point
|
| 229 |
conversion subrank [[conv.rank]] of `FP2` is greater than the
|
| 230 |
subrank of `T3`.
|
| 231 |
+
\[*Example 9*:
|
| 232 |
``` cpp
|
| 233 |
int f(std::float32_t);
|
| 234 |
int f(std::float64_t);
|
| 235 |
int f(long long);
|
| 236 |
float x;
|
|
|
|
| 247 |
of `B*` to `void*`.
|
| 248 |
- If class `B` is derived directly or indirectly from class `A` and
|
| 249 |
class `C` is derived directly or indirectly from `B`,
|
| 250 |
- conversion of `C*` to `B*` is better than conversion of `C*` to
|
| 251 |
`A*`,
|
| 252 |
+
\[*Example 10*:
|
| 253 |
``` cpp
|
| 254 |
struct A {};
|
| 255 |
struct B : public A {};
|
| 256 |
struct C : public B {};
|
| 257 |
C* pc;
|