From Jason Turner

[temp.constr.order]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfdwd_nr_/{from.md → to.md} +64 -0
tmp/tmpfdwd_nr_/{from.md → to.md} RENAMED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Partial ordering by constraints <a id="temp.constr.order">[[temp.constr.order]]</a>
2
+
3
+ A constraint P *subsumes* a constraint Q if and only if, for every
4
+ disjunctive clause Pᵢ in the disjunctive normal form[^4] of P, Pᵢ
5
+ subsumes every conjunctive clause Qⱼ in the conjunctive normal form[^5]
6
+ of Q, where
7
+
8
+ - a disjunctive clause Pᵢ subsumes a conjunctive clause Qⱼ if and only
9
+ if there exists an atomic constraint Pᵢₐ in Pᵢ for which there exists
10
+ an atomic constraint $Q_{jb}$ in Qⱼ such that Pᵢₐ subsumes $Q_{jb}$,
11
+ and
12
+ - an atomic constraint A subsumes another atomic constraint B if and
13
+ only if A and B are identical using the rules described in
14
+ [[temp.constr.atomic]].
15
+
16
+ [*Example 1*: Let A and B be atomic constraints [[temp.constr.atomic]].
17
+ The constraint A ∧ B subsumes A, but A does not subsume A ∧ B. The
18
+ constraint A subsumes A ∨ B, but A ∨ B does not subsume A. Also note
19
+ that every constraint subsumes itself. — *end example*]
20
+
21
+ [*Note 1*:
22
+
23
+ The subsumption relation defines a partial ordering on constraints. This
24
+ partial ordering is used to determine
25
+
26
+ - the best viable candidate of non-template functions
27
+ [[over.match.best]],
28
+ - the address of a non-template function [[over.over]],
29
+ - the matching of template template arguments [[temp.arg.template]],
30
+ - the partial ordering of class template specializations
31
+ [[temp.class.order]], and
32
+ - the partial ordering of function templates [[temp.func.order]].
33
+
34
+ — *end note*]
35
+
36
+ A declaration `D1` is *at least as constrained* as a declaration `D2` if
37
+
38
+ - `D1` and `D2` are both constrained declarations and `D1`’s associated
39
+ constraints subsume those of `D2`; or
40
+ - `D2` has no associated constraints.
41
+
42
+ A declaration `D1` is *more constrained* than another declaration `D2`
43
+ when `D1` is at least as constrained as `D2`, and `D2` is not at least
44
+ as constrained as `D1`.
45
+
46
+ [*Example 2*:
47
+
48
+ ``` cpp
49
+ template<typename T> concept C1 = requires(T t) { --t; };
50
+ template<typename T> concept C2 = C1<T> && requires(T t) { *t; };
51
+
52
+ template<C1 T> void f(T); // #1
53
+ template<C2 T> void f(T); // #2
54
+ template<typename T> void g(T); // #3
55
+ template<C1 T> void g(T); // #4
56
+
57
+ f(0); // selects #1
58
+ f((int*)0); // selects #2
59
+ g(true); // selects #3 because C1<bool> is not satisfied
60
+ g(0); // selects #4
61
+ ```
62
+
63
+ — *end example*]
64
+