tmp/tmpdvt5s8t7/{from.md → to.md}
RENAMED
|
@@ -1,54 +1,64 @@
|
|
| 1 |
### Relationships between types <a id="meta.rel">[[meta.rel]]</a>
|
| 2 |
|
| 3 |
-
This
|
| 4 |
relationships between types at compile time.
|
| 5 |
|
| 6 |
-
Each of these templates shall be a BinaryTypeTrait ([[meta.rqmts]])
|
| 7 |
-
with a
|
| 8 |
is true, otherwise `false_type`.
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
``` cpp
|
| 11 |
struct B {};
|
| 12 |
struct B1 : B {};
|
| 13 |
struct B2 : B {};
|
| 14 |
struct D : private B1, private B2 {};
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
```
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
template <class T>
|
| 30 |
-
add_rvalue_reference_t<T> create() noexcept;
|
| 31 |
-
```
|
| 32 |
-
|
| 33 |
-
the predicate condition for a template specialization
|
| 34 |
`is_convertible<From, To>` shall be satisfied if and only if the return
|
| 35 |
expression in the following code would be well-formed, including any
|
| 36 |
implicit conversions to the return type of the function:
|
| 37 |
|
| 38 |
``` cpp
|
| 39 |
To test() {
|
| 40 |
-
return
|
| 41 |
}
|
| 42 |
```
|
| 43 |
|
| 44 |
-
This requirement gives well defined results for reference
|
| 45 |
-
types, array types, and function types.
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 54 |
|
|
|
|
| 1 |
### Relationships between types <a id="meta.rel">[[meta.rel]]</a>
|
| 2 |
|
| 3 |
+
This subclause contains templates that may be used to query
|
| 4 |
relationships between types at compile time.
|
| 5 |
|
| 6 |
+
Each of these templates shall be a `BinaryTypeTrait` ([[meta.rqmts]])
|
| 7 |
+
with a base characteristic of `true_type` if the corresponding condition
|
| 8 |
is true, otherwise `false_type`.
|
| 9 |
|
| 10 |
+
[*Note 1*: Base classes that are private, protected, or ambiguous are,
|
| 11 |
+
nonetheless, base classes. — *end note*]
|
| 12 |
+
|
| 13 |
+
For the purpose of defining the templates in this subclause, a function
|
| 14 |
+
call expression `declval<T>()` for any type `T` is considered to be a
|
| 15 |
+
trivial ([[basic.types]], [[special]]) function call that is not an
|
| 16 |
+
odr-use ([[basic.def.odr]]) of `declval` in the context of the
|
| 17 |
+
corresponding definition notwithstanding the restrictions of
|
| 18 |
+
[[declval]].
|
| 19 |
+
|
| 20 |
+
[*Example 1*:
|
| 21 |
+
|
| 22 |
``` cpp
|
| 23 |
struct B {};
|
| 24 |
struct B1 : B {};
|
| 25 |
struct B2 : B {};
|
| 26 |
struct D : private B1, private B2 {};
|
| 27 |
|
| 28 |
+
is_base_of_v<B, D> // true
|
| 29 |
+
is_base_of_v<const B, D> // true
|
| 30 |
+
is_base_of_v<B, const D> // true
|
| 31 |
+
is_base_of_v<B, const B> // true
|
| 32 |
+
is_base_of_v<D, B> // false
|
| 33 |
+
is_base_of_v<B&, D&> // false
|
| 34 |
+
is_base_of_v<B[3], D[3]> // false
|
| 35 |
+
is_base_of_v<int, int> // false
|
| 36 |
```
|
| 37 |
|
| 38 |
+
— *end example*]
|
| 39 |
|
| 40 |
+
The predicate condition for a template specialization
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
`is_convertible<From, To>` shall be satisfied if and only if the return
|
| 42 |
expression in the following code would be well-formed, including any
|
| 43 |
implicit conversions to the return type of the function:
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
To test() {
|
| 47 |
+
return declval<From>();
|
| 48 |
}
|
| 49 |
```
|
| 50 |
|
| 51 |
+
[*Note 2*: This requirement gives well defined results for reference
|
| 52 |
+
types, void types, array types, and function types. — *end note*]
|
| 53 |
+
|
| 54 |
+
Access checking is performed in a context unrelated to `To` and `From`.
|
| 55 |
+
Only the validity of the immediate context of the *expression* of the
|
| 56 |
+
`return` statement (including initialization of the returned object or
|
| 57 |
+
reference) is considered.
|
| 58 |
+
|
| 59 |
+
[*Note 3*: The initialization can result in side effects such as the
|
| 60 |
+
instantiation of class template specializations and function template
|
| 61 |
+
specializations, the generation of implicitly-defined functions, and so
|
| 62 |
+
on. Such side effects are not in the “immediate context” and can result
|
| 63 |
+
in the program being ill-formed. — *end note*]
|
| 64 |
|