From Jason Turner

[meta.rel]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpdvt5s8t7/{from.md → to.md} +39 -29
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 sub-clause 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 BaseCharacteristic of `true_type` if the corresponding condition
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
- is_base_of<B, D>::value // true
17
- is_base_of<const B, D>::value // true
18
- is_base_of<B, const D>::value // true
19
- is_base_of<B, const B>::value // true
20
- is_base_of<D, B>::value // false
21
- is_base_of<B&, D&>::value // false
22
- is_base_of<B[3], D[3]>::value // false
23
- is_base_of<int, int>::value // false
24
  ```
25
 
26
- Given the following function prototype:
27
 
28
- ``` cpp
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 create<From>();
41
  }
42
  ```
43
 
44
- This requirement gives well defined results for reference types, void
45
- types, array types, and function types.Access checking is performed as
46
- if in a context unrelated to `To` and `From`. Only the validity of the
47
- immediate context of the expression of the *return-statement* (including
48
- conversions to the return type) is considered. The evaluation of the
49
- conversion can result in side effects such as the instantiation of class
50
- template specializations and function template specializations, the
51
- generation of implicitly-defined functions, and so on. Such side effects
52
- are not in the “immediate context” and can result in the program being
53
- ill-formed.
 
 
 
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