tmp/tmprqgvp3gn/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="class.conv.general">[[class.conv.general]]</a>
|
| 2 |
+
|
| 3 |
+
Type conversions of class objects can be specified by constructors and
|
| 4 |
+
by conversion functions. These conversions are called *user-defined
|
| 5 |
+
conversions* and are used for implicit type conversions [[conv]], for
|
| 6 |
+
initialization [[dcl.init]], and for explicit type conversions
|
| 7 |
+
[[expr.type.conv]], [[expr.cast]], [[expr.static.cast]].
|
| 8 |
+
|
| 9 |
+
User-defined conversions are applied only where they are unambiguous
|
| 10 |
+
[[class.member.lookup]], [[class.conv.fct]]. Conversions obey the access
|
| 11 |
+
control rules [[class.access]]. Access control is applied after
|
| 12 |
+
ambiguity resolution [[basic.lookup]].
|
| 13 |
+
|
| 14 |
+
[*Note 1*: See [[over.match]] for a discussion of the use of
|
| 15 |
+
conversions in function calls as well as examples below. — *end note*]
|
| 16 |
+
|
| 17 |
+
At most one user-defined conversion (constructor or conversion function)
|
| 18 |
+
is implicitly applied to a single value.
|
| 19 |
+
|
| 20 |
+
[*Example 1*:
|
| 21 |
+
|
| 22 |
+
``` cpp
|
| 23 |
+
struct X {
|
| 24 |
+
operator int();
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
struct Y {
|
| 28 |
+
operator X();
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
Y a;
|
| 32 |
+
int b = a; // error: no viable conversion (a.operator X().operator int() not considered)
|
| 33 |
+
int c = X(a); // OK, a.operator X().operator int()
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
— *end example*]
|
| 37 |
+
|