tmp/tmpe4olnzhl/{from.md → to.md}
RENAMED
|
@@ -29,23 +29,10 @@ conversion sequences unless one of the following rules applies:
|
|
| 29 |
sequence is considered to be a subsequence of any non-identity
|
| 30 |
conversion sequence) or, if not that,
|
| 31 |
- the rank of `S1` is better than the rank of `S2`, or `S1` and `S2`
|
| 32 |
have the same rank and are distinguishable by the rules in the
|
| 33 |
paragraph below, or, if not that,
|
| 34 |
-
- `S1`
|
| 35 |
-
and `S2` differ only in their qualification conversion and yield
|
| 36 |
-
similar types `T1` and `T2` ([[conv.qual]]), respectively, and the
|
| 37 |
-
cv-qualification signature of type `T1` is a proper subset of the
|
| 38 |
-
cv-qualification signature of type `T2`.
|
| 39 |
-
``` cpp
|
| 40 |
-
int f(const int *);
|
| 41 |
-
int f(int *);
|
| 42 |
-
int i;
|
| 43 |
-
int j = f(&i); // calls f(int*)
|
| 44 |
-
```
|
| 45 |
-
|
| 46 |
-
or, if not that,
|
| 47 |
- `S1` and `S2` are reference bindings ([[dcl.init.ref]]) and neither
|
| 48 |
refers to an implicit object parameter of a non-static member
|
| 49 |
function declared without a *ref-qualifier*, and `S1` binds an
|
| 50 |
rvalue reference to an rvalue and `S2` binds an lvalue reference.
|
| 51 |
``` cpp
|
|
@@ -76,15 +63,30 @@ conversion sequences unless one of the following rules applies:
|
|
| 76 |
or, if not that,
|
| 77 |
- `S1` and `S2` are reference bindings ([[dcl.init.ref]]) and `S1`
|
| 78 |
binds an lvalue reference to a function lvalue and `S2` binds an
|
| 79 |
rvalue reference to a function lvalue.
|
| 80 |
``` cpp
|
| 81 |
-
|
| 82 |
-
|
| 83 |
void g();
|
| 84 |
-
int i1 = f(g); // calls
|
| 85 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
- `S1`
|
| 87 |
and `S2` are reference bindings ([[dcl.init.ref]]), and the types
|
| 88 |
to which the references refer are the same type except for top-level
|
| 89 |
cv-qualifiers, and the type to which the reference initialized by
|
| 90 |
`S2` refers is more cv-qualified than the type to which the
|
|
@@ -108,33 +110,40 @@ conversion sequences unless one of the following rules applies:
|
|
| 108 |
b.f(); // calls X::f()
|
| 109 |
}
|
| 110 |
```
|
| 111 |
- User-defined conversion sequence `U1` is a better conversion sequence
|
| 112 |
than another user-defined conversion sequence `U2` if they contain the
|
| 113 |
-
same user-defined conversion function or constructor or
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
``` cpp
|
| 117 |
struct A {
|
| 118 |
operator short();
|
| 119 |
} a;
|
| 120 |
int f(int);
|
| 121 |
int f(float);
|
| 122 |
int i = f(a); // calls f(int), because short → int is
|
| 123 |
// better than short → float.
|
| 124 |
```
|
| 125 |
- List-initialization sequence `L1` is a better conversion sequence than
|
| 126 |
-
list-initialization sequence `L2` if
|
| 127 |
-
`std::initializer_list<X>` for some `X` and `L2`
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
Standard conversion sequences are ordered by their ranks: an Exact Match
|
| 130 |
is a better conversion than a Promotion, which is a better conversion
|
| 131 |
than a Conversion. Two conversion sequences with the same rank are
|
| 132 |
indistinguishable unless one of the following rules applies:
|
| 133 |
|
| 134 |
- A conversion that does not convert a pointer, a pointer to member, or
|
| 135 |
`std::nullptr_t` to `bool` is better than one that does.
|
|
|
|
|
|
|
|
|
|
| 136 |
- If class `B` is derived directly or indirectly from class `A`,
|
| 137 |
conversion of `B*` to `A*` is better than conversion of `B*` to
|
| 138 |
`void*`, and conversion of `A*` to `void*` is better than conversion
|
| 139 |
of `B*` to `void*`.
|
| 140 |
- If class `B` is derived directly or indirectly from class `A` and
|
|
@@ -148,21 +157,21 @@ indistinguishable unless one of the following rules applies:
|
|
| 148 |
C* pc;
|
| 149 |
int f(A*);
|
| 150 |
int f(B*);
|
| 151 |
int i = f(pc); // calls f(B*)
|
| 152 |
```
|
| 153 |
-
- binding of an expression of type `C` to a reference
|
| 154 |
-
better than binding an expression of type `C` to a reference
|
| 155 |
-
`A
|
| 156 |
- conversion of `A::*` to `B::*` is better than conversion of `A::*`
|
| 157 |
to `C::*`,
|
| 158 |
- conversion of `C` to `B` is better than conversion of `C` to `A`,
|
| 159 |
- conversion of `B*` to `A*` is better than conversion of `C*` to
|
| 160 |
`A*`,
|
| 161 |
-
- binding of an expression of type `B` to a reference
|
| 162 |
-
better than binding an expression of type `C` to a reference
|
| 163 |
-
`A
|
| 164 |
- conversion of `B::*` to `C::*` is better than conversion of `A::*`
|
| 165 |
to `C::*`, and
|
| 166 |
- conversion of `B` to `A` is better than conversion of `C` to `A`.
|
| 167 |
|
| 168 |
Compared conversion sequences will have different source types only in
|
|
|
|
| 29 |
sequence is considered to be a subsequence of any non-identity
|
| 30 |
conversion sequence) or, if not that,
|
| 31 |
- the rank of `S1` is better than the rank of `S2`, or `S1` and `S2`
|
| 32 |
have the same rank and are distinguishable by the rules in the
|
| 33 |
paragraph below, or, if not that,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
- `S1` and `S2` are reference bindings ([[dcl.init.ref]]) and neither
|
| 35 |
refers to an implicit object parameter of a non-static member
|
| 36 |
function declared without a *ref-qualifier*, and `S1` binds an
|
| 37 |
rvalue reference to an rvalue and `S2` binds an lvalue reference.
|
| 38 |
``` cpp
|
|
|
|
| 63 |
or, if not that,
|
| 64 |
- `S1` and `S2` are reference bindings ([[dcl.init.ref]]) and `S1`
|
| 65 |
binds an lvalue reference to a function lvalue and `S2` binds an
|
| 66 |
rvalue reference to a function lvalue.
|
| 67 |
``` cpp
|
| 68 |
+
int f(void(&)()); // #1
|
| 69 |
+
int f(void(&&)()); // #2
|
| 70 |
void g();
|
| 71 |
+
int i1 = f(g); // calls #1
|
| 72 |
```
|
| 73 |
+
|
| 74 |
+
or, if not that,
|
| 75 |
+
- `S1`
|
| 76 |
+
and `S2` differ only in their qualification conversion and yield
|
| 77 |
+
similar types `T1` and `T2` ([[conv.qual]]), respectively, and the
|
| 78 |
+
cv-qualification signature of type `T1` is a proper subset of the
|
| 79 |
+
cv-qualification signature of type `T2`.
|
| 80 |
+
``` cpp
|
| 81 |
+
int f(const volatile int *);
|
| 82 |
+
int f(const int *);
|
| 83 |
+
int i;
|
| 84 |
+
int j = f(&i); // calls f(const int*)
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
or, if not that,
|
| 88 |
- `S1`
|
| 89 |
and `S2` are reference bindings ([[dcl.init.ref]]), and the types
|
| 90 |
to which the references refer are the same type except for top-level
|
| 91 |
cv-qualifiers, and the type to which the reference initialized by
|
| 92 |
`S2` refers is more cv-qualified than the type to which the
|
|
|
|
| 110 |
b.f(); // calls X::f()
|
| 111 |
}
|
| 112 |
```
|
| 113 |
- User-defined conversion sequence `U1` is a better conversion sequence
|
| 114 |
than another user-defined conversion sequence `U2` if they contain the
|
| 115 |
+
same user-defined conversion function or constructor or they
|
| 116 |
+
initialize the same class in an aggregate initialization and in either
|
| 117 |
+
case the second standard conversion sequence of `U1` is better than
|
| 118 |
+
the second standard conversion sequence of `U2`.
|
| 119 |
``` cpp
|
| 120 |
struct A {
|
| 121 |
operator short();
|
| 122 |
} a;
|
| 123 |
int f(int);
|
| 124 |
int f(float);
|
| 125 |
int i = f(a); // calls f(int), because short → int is
|
| 126 |
// better than short → float.
|
| 127 |
```
|
| 128 |
- List-initialization sequence `L1` is a better conversion sequence than
|
| 129 |
+
list-initialization sequence `L2` if
|
| 130 |
+
- `L1` converts to `std::initializer_list<X>` for some `X` and `L2`
|
| 131 |
+
does not, or, if not that,
|
| 132 |
+
- `L1` converts to type “array of `N1` `T`”, `L2` converts to type
|
| 133 |
+
“array of `N2` `T`”, and `N1` is smaller than `N2`.
|
| 134 |
|
| 135 |
Standard conversion sequences are ordered by their ranks: an Exact Match
|
| 136 |
is a better conversion than a Promotion, which is a better conversion
|
| 137 |
than a Conversion. Two conversion sequences with the same rank are
|
| 138 |
indistinguishable unless one of the following rules applies:
|
| 139 |
|
| 140 |
- A conversion that does not convert a pointer, a pointer to member, or
|
| 141 |
`std::nullptr_t` to `bool` is better than one that does.
|
| 142 |
+
- A conversion that promotes an enumeration whose underlying type is
|
| 143 |
+
fixed to its underlying type is better than one that promotes to the
|
| 144 |
+
promoted underlying type, if the two are different.
|
| 145 |
- If class `B` is derived directly or indirectly from class `A`,
|
| 146 |
conversion of `B*` to `A*` is better than conversion of `B*` to
|
| 147 |
`void*`, and conversion of `A*` to `void*` is better than conversion
|
| 148 |
of `B*` to `void*`.
|
| 149 |
- If class `B` is derived directly or indirectly from class `A` and
|
|
|
|
| 157 |
C* pc;
|
| 158 |
int f(A*);
|
| 159 |
int f(B*);
|
| 160 |
int i = f(pc); // calls f(B*)
|
| 161 |
```
|
| 162 |
+
- binding of an expression of type `C` to a reference to type `B` is
|
| 163 |
+
better than binding an expression of type `C` to a reference to type
|
| 164 |
+
`A`,
|
| 165 |
- conversion of `A::*` to `B::*` is better than conversion of `A::*`
|
| 166 |
to `C::*`,
|
| 167 |
- conversion of `C` to `B` is better than conversion of `C` to `A`,
|
| 168 |
- conversion of `B*` to `A*` is better than conversion of `C*` to
|
| 169 |
`A*`,
|
| 170 |
+
- binding of an expression of type `B` to a reference to type `A` is
|
| 171 |
+
better than binding an expression of type `C` to a reference to type
|
| 172 |
+
`A`,
|
| 173 |
- conversion of `B::*` to `C::*` is better than conversion of `A::*`
|
| 174 |
to `C::*`, and
|
| 175 |
- conversion of `B` to `A` is better than conversion of `C` to `A`.
|
| 176 |
|
| 177 |
Compared conversion sequences will have different source types only in
|