From Jason Turner

[tuple.rel]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpckevb9q4/{from.md → to.md} +40 -16
tmp/tmpckevb9q4/{from.md → to.md} RENAMED
@@ -1,43 +1,67 @@
1
  ### Relational operators <a id="tuple.rel">[[tuple.rel]]</a>
2
 
3
  ``` cpp
4
  template<class... TTypes, class... UTypes>
5
  constexpr bool operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
 
 
6
  ```
7
 
 
 
8
  *Mandates:* For all `i`, where 0 ≤ `i` < `sizeof...(TTypes)`,
9
- `get<i>(t) == get<i>(u)` is a valid expression returning a type that is
10
- convertible to `bool`. `sizeof...(TTypes)` equals `sizeof...(UTypes)`.
 
 
 
11
 
12
  *Returns:* `true` if `get<i>(t) == get<i>(u)` for all `i`, otherwise
13
- `false`. For any two zero-length tuples `e` and `f`, `e == f` returns
14
- `true`.
15
 
16
- *Effects:* The elementary comparisons are performed in order from the
17
- zeroth index upwards. No comparisons or element accesses are performed
18
- after the first equality comparison that evaluates to `false`.
 
 
 
 
 
 
 
19
 
20
  ``` cpp
21
  template<class... TTypes, class... UTypes>
22
  constexpr common_comparison_category_t<synth-three-way-result<TTypes, UTypes>...>
23
  operator<=>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
 
 
 
24
  ```
25
 
26
- *Effects:* Performs a lexicographical comparison between `t` and `u`.
27
- For any two zero-length tuples `t` and `u`, `t <=> u` returns
28
- `strong_ordering::equal`. Otherwise, equivalent to:
 
 
 
 
29
 
30
  ``` cpp
31
  if (auto c = synth-three-way(get<0>(t), get<0>(u)); c != 0) return c;
32
  return $t_tail$ <=> $u_tail$;
33
  ```
34
 
35
- where `r_tail` for some tuple `r` is a tuple containing all but the
36
- first element of `r`.
 
 
 
37
 
38
  [*Note 1*: The above definition does not require `tₜₐᵢₗ` (or `uₜₐᵢₗ`)
39
- to be constructed. It may not even be possible, as `t` and `u` are not
40
- required to be copy constructible. Also, all comparison functions are
41
- short circuited; they do not perform element accesses beyond what is
42
- required to determine the result of the comparison. — *end note*]
 
43
 
 
1
  ### Relational operators <a id="tuple.rel">[[tuple.rel]]</a>
2
 
3
  ``` cpp
4
  template<class... TTypes, class... UTypes>
5
  constexpr bool operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
6
+ template<class... TTypes, tuple-like UTuple>
7
+ constexpr bool operator==(const tuple<TTypes...>& t, const UTuple& u);
8
  ```
9
 
10
+ For the first overload let `UTuple` be `tuple<UTypes...>`.
11
+
12
  *Mandates:* For all `i`, where 0 ≤ `i` < `sizeof...(TTypes)`,
13
+ `get<i>(t) == get<i>(u)` is a valid expression. `sizeof...(TTypes)`
14
+ equals `tuple_size_v<UTuple>`.
15
+
16
+ *Preconditions:* For all `i`, `decltype(get<i>(t) == get<i>(u))` models
17
+ `boolean-testable`.
18
 
19
  *Returns:* `true` if `get<i>(t) == get<i>(u)` for all `i`, otherwise
20
+ `false`.
 
21
 
22
+ [*Note 1*: If `sizeof...(TTypes)` equals zero, returns
23
+ `true`. *end note*]
24
+
25
+ *Remarks:*
26
+
27
+ - The elementary comparisons are performed in order from the zeroth
28
+ index upwards. No comparisons or element accesses are performed after
29
+ the first equality comparison that evaluates to `false`.
30
+ - The second overload is to be found via argument-dependent
31
+ lookup [[basic.lookup.argdep]] only.
32
 
33
  ``` cpp
34
  template<class... TTypes, class... UTypes>
35
  constexpr common_comparison_category_t<synth-three-way-result<TTypes, UTypes>...>
36
  operator<=>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
37
+ template<class... TTypes, tuple-like UTuple>
38
+ constexpr common_comparison_category_t<synth-three-way-result<TTypes, Elems>...>
39
+ operator<=>(const tuple<TTypes...>& t, const UTuple& u);
40
  ```
41
 
42
+ For the second overload, `Elems` denotes the pack of types
43
+ `tuple_element_t<0, UTuple>`, `tuple_element_t<1, UTuple>`, …,
44
+ `tuple_element_t<tuple_size_v<UTuple> - 1, UTuple>`.
45
+
46
+ *Effects:* Performs a lexicographical comparison between `t` and `u`. If
47
+ `sizeof...(TTypes)` equals zero, returns `strong_ordering::equal`.
48
+ Otherwise, equivalent to:
49
 
50
  ``` cpp
51
  if (auto c = synth-three-way(get<0>(t), get<0>(u)); c != 0) return c;
52
  return $t_tail$ <=> $u_tail$;
53
  ```
54
 
55
+ where `r_tail` for some `r` is a tuple containing all but the first
56
+ element of `r`.
57
+
58
+ *Remarks:* The second overload is to be found via argument-dependent
59
+ lookup [[basic.lookup.argdep]] only.
60
 
61
  [*Note 1*: The above definition does not require `tₜₐᵢₗ` (or `uₜₐᵢₗ`)
62
+ to be constructed. It might not even be possible, as `t` and `u` are not
63
+ required to be copy constructible. Also, all comparison operator
64
+ functions are short circuited; they do not perform element accesses
65
+ beyond what is required to determine the result of the
66
+ comparison. — *end note*]
67