From Jason Turner

[temp.constr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0numiwg5/{from.md → to.md} +18 -11
tmp/tmp0numiwg5/{from.md → to.md} RENAMED
@@ -1,15 +1,19 @@
1
  ## Template constraints <a id="temp.constr">[[temp.constr]]</a>
2
 
3
- [*Note 1*: This subclause defines the meaning of constraints on
4
- template arguments. The abstract syntax and satisfaction rules are
 
 
5
  defined in [[temp.constr.constr]]. Constraints are associated with
6
  declarations in [[temp.constr.decl]]. Declarations are partially ordered
7
  by their associated constraints [[temp.constr.order]]. — *end note*]
8
 
9
  ### Constraints <a id="temp.constr.constr">[[temp.constr.constr]]</a>
10
 
 
 
11
  A *constraint* is a sequence of logical operations and operands that
12
  specifies requirements on template arguments. The operands of a logical
13
  operation are constraints. There are three different kinds of
14
  constraints:
15
 
@@ -60,11 +64,11 @@ template<typename T>
60
  requires (sizeof(T) > 1) && (get_value<T>())
61
  void f(T); // has associated constraint sizeof(T) > 1 ∧ get_value<T>()
62
 
63
  void f(int);
64
 
65
- f('a'); // OK: calls f(int)
66
  ```
67
 
68
  In the satisfaction of the associated constraints [[temp.constr.decl]]
69
  of `f`, the constraint `sizeof(char) > 1` is not satisfied; the second
70
  operand is not checked for satisfaction.
@@ -171,14 +175,14 @@ void h() {
171
  }
172
  ```
173
 
174
  — *end example*]
175
 
176
- This similarity includes the situation where a program is ill-formed, no
177
- diagnostic required, when the meaning of the program depends on whether
178
- two constructs are equivalent, and they are functionally equivalent but
179
- not equivalent.
180
 
181
  [*Example 2*:
182
 
183
  ``` cpp
184
  template <unsigned N> void f2()
@@ -379,11 +383,11 @@ names a concept specialization [[expr.prim.id]]. — *end note*]
379
 
380
  ``` cpp
381
  template<typename T> concept C1 = sizeof(T) == 1;
382
  template<typename T> concept C2 = C1<T> && 1 == 2;
383
  template<typename T> concept C3 = requires { typename T::type; };
384
- template<typename T> concept C4 = requires (T x) { ++x; }
385
 
386
  template<C2 U> void f1(U); // #1
387
  template<C3 U> void f2(U); // #2
388
  template<C4 U> void f3(U); // #3
389
  ```
@@ -398,12 +402,15 @@ mapping `T` ↦ `U`).
398
  — *end example*]
399
 
400
  ### Partial ordering by constraints <a id="temp.constr.order">[[temp.constr.order]]</a>
401
 
402
  A constraint P *subsumes* a constraint Q if and only if, for every
403
- disjunctive clause Pᵢ in the disjunctive normal form[^4] of P, Pᵢ
404
- subsumes every conjunctive clause Qⱼ in the conjunctive normal form[^5]
 
 
 
405
  of Q, where
406
 
407
  - a disjunctive clause Pᵢ subsumes a conjunctive clause Qⱼ if and only
408
  if there exists an atomic constraint Pᵢₐ in Pᵢ for which there exists
409
  an atomic constraint $Q_{jb}$ in Qⱼ such that Pᵢₐ subsumes $Q_{jb}$,
@@ -425,11 +432,11 @@ partial ordering is used to determine
425
  - the best viable candidate of non-template functions
426
  [[over.match.best]],
427
  - the address of a non-template function [[over.over]],
428
  - the matching of template template arguments [[temp.arg.template]],
429
  - the partial ordering of class template specializations
430
- [[temp.class.order]], and
431
  - the partial ordering of function templates [[temp.func.order]].
432
 
433
  — *end note*]
434
 
435
  A declaration `D1` is *at least as constrained* as a declaration `D2` if
 
1
  ## Template constraints <a id="temp.constr">[[temp.constr]]</a>
2
 
3
+ ### General <a id="temp.constr.general">[[temp.constr.general]]</a>
4
+
5
+ [*Note 1*: Subclause [[temp.constr]] defines the meaning of constraints
6
+ on template arguments. The abstract syntax and satisfaction rules are
7
  defined in [[temp.constr.constr]]. Constraints are associated with
8
  declarations in [[temp.constr.decl]]. Declarations are partially ordered
9
  by their associated constraints [[temp.constr.order]]. — *end note*]
10
 
11
  ### Constraints <a id="temp.constr.constr">[[temp.constr.constr]]</a>
12
 
13
+ #### General <a id="temp.constr.constr.general">[[temp.constr.constr.general]]</a>
14
+
15
  A *constraint* is a sequence of logical operations and operands that
16
  specifies requirements on template arguments. The operands of a logical
17
  operation are constraints. There are three different kinds of
18
  constraints:
19
 
 
64
  requires (sizeof(T) > 1) && (get_value<T>())
65
  void f(T); // has associated constraint sizeof(T) > 1 ∧ get_value<T>()
66
 
67
  void f(int);
68
 
69
+ f('a'); // OK, calls f(int)
70
  ```
71
 
72
  In the satisfaction of the associated constraints [[temp.constr.decl]]
73
  of `f`, the constraint `sizeof(char) > 1` is not satisfied; the second
74
  operand is not checked for satisfaction.
 
175
  }
176
  ```
177
 
178
  — *end example*]
179
 
180
+ As specified in [[temp.over.link]], if the validity or meaning of the
181
+ program depends on whether two constructs are equivalent, and they are
182
+ functionally equivalent but not equivalent, the program is ill-formed,
183
+ no diagnostic required.
184
 
185
  [*Example 2*:
186
 
187
  ``` cpp
188
  template <unsigned N> void f2()
 
383
 
384
  ``` cpp
385
  template<typename T> concept C1 = sizeof(T) == 1;
386
  template<typename T> concept C2 = C1<T> && 1 == 2;
387
  template<typename T> concept C3 = requires { typename T::type; };
388
+ template<typename T> concept C4 = requires (T x) { ++x; };
389
 
390
  template<C2 U> void f1(U); // #1
391
  template<C3 U> void f2(U); // #2
392
  template<C4 U> void f3(U); // #3
393
  ```
 
402
  — *end example*]
403
 
404
  ### Partial ordering by constraints <a id="temp.constr.order">[[temp.constr.order]]</a>
405
 
406
  A constraint P *subsumes* a constraint Q if and only if, for every
407
+ disjunctive clause Pᵢ in the disjunctive normal form[^4]
408
+
409
+ of P, Pᵢ subsumes every conjunctive clause Qⱼ in the conjunctive normal
410
+ form[^5]
411
+
412
  of Q, where
413
 
414
  - a disjunctive clause Pᵢ subsumes a conjunctive clause Qⱼ if and only
415
  if there exists an atomic constraint Pᵢₐ in Pᵢ for which there exists
416
  an atomic constraint $Q_{jb}$ in Qⱼ such that Pᵢₐ subsumes $Q_{jb}$,
 
432
  - the best viable candidate of non-template functions
433
  [[over.match.best]],
434
  - the address of a non-template function [[over.over]],
435
  - the matching of template template arguments [[temp.arg.template]],
436
  - the partial ordering of class template specializations
437
+ [[temp.spec.partial.order]], and
438
  - the partial ordering of function templates [[temp.func.order]].
439
 
440
  — *end note*]
441
 
442
  A declaration `D1` is *at least as constrained* as a declaration `D2` if