From Jason Turner

[variant.relops]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpjup77iuf/{from.md → to.md} +31 -12
tmp/tmpjup77iuf/{from.md → to.md} RENAMED
@@ -3,36 +3,36 @@
3
  ``` cpp
4
  template<class... Types>
5
  constexpr bool operator==(const variant<Types...>& v, const variant<Types...>& w);
6
  ```
7
 
8
- *Requires:* `get<`i`>(v) == get<`i`>(w)` is a valid expression returning
9
- a type that is convertible to `bool`, for all i.
10
 
11
  *Returns:* If `v.index() != w.index()`, `false`; otherwise if
12
  `v.valueless_by_exception()`, `true`; otherwise
13
  `get<`i`>(v) == get<`i`>(w)` with i being `v.index()`.
14
 
15
  ``` cpp
16
  template<class... Types>
17
  constexpr bool operator!=(const variant<Types...>& v, const variant<Types...>& w);
18
  ```
19
 
20
- *Requires:* `get<`i`>(v) != get<`i`>(w)` is a valid expression returning
21
- a type that is convertible to `bool`, for all i.
22
 
23
  *Returns:* If `v.index() != w.index()`, `true`; otherwise if
24
  `v.valueless_by_exception()`, `false`; otherwise
25
  `get<`i`>(v) != get<`i`>(w)` with i being `v.index()`.
26
 
27
  ``` cpp
28
  template<class... Types>
29
  constexpr bool operator<(const variant<Types...>& v, const variant<Types...>& w);
30
  ```
31
 
32
- *Requires:* `get<`i`>(v) < get<`i`>(w)` is a valid expression returning
33
- a type that is convertible to `bool`, for all i.
34
 
35
  *Returns:* If `w.valueless_by_exception()`, `false`; otherwise if
36
  `v.valueless_by_exception()`, `true`; otherwise, if
37
  `v.index() < w.index()`, `true`; otherwise if `v.index() > w.index()`,
38
  `false`; otherwise `get<`i`>(v) < get<`i`>(w)` with i being `v.index()`.
@@ -40,12 +40,12 @@ a type that is convertible to `bool`, for all i.
40
  ``` cpp
41
  template<class... Types>
42
  constexpr bool operator>(const variant<Types...>& v, const variant<Types...>& w);
43
  ```
44
 
45
- *Requires:* `get<`i`>(v) > get<`i`>(w)` is a valid expression returning
46
- a type that is convertible to `bool`, for all i.
47
 
48
  *Returns:* If `v.valueless_by_exception()`, `false`; otherwise if
49
  `w.valueless_by_exception()`, `true`; otherwise, if
50
  `v.index() > w.index()`, `true`; otherwise if `v.index() < w.index()`,
51
  `false`; otherwise `get<`i`>(v) > get<`i`>(w)` with i being `v.index()`.
@@ -53,12 +53,12 @@ a type that is convertible to `bool`, for all i.
53
  ``` cpp
54
  template<class... Types>
55
  constexpr bool operator<=(const variant<Types...>& v, const variant<Types...>& w);
56
  ```
57
 
58
- *Requires:* `get<`i`>(v) <= get<`i`>(w)` is a valid expression returning
59
- a type that is convertible to `bool`, for all i.
60
 
61
  *Returns:* If `v.valueless_by_exception()`, `true`; otherwise if
62
  `w.valueless_by_exception()`, `false`; otherwise, if
63
  `v.index() < w.index()`, `true`; otherwise if `v.index() > w.index()`,
64
  `false`; otherwise `get<`i`>(v) <= get<`i`>(w)` with i being
@@ -67,14 +67,33 @@ a type that is convertible to `bool`, for all i.
67
  ``` cpp
68
  template<class... Types>
69
  constexpr bool operator>=(const variant<Types...>& v, const variant<Types...>& w);
70
  ```
71
 
72
- *Requires:* `get<`i`>(v) >= get<`i`>(w)` is a valid expression returning
73
- a type that is convertible to `bool`, for all i.
74
 
75
  *Returns:* If `w.valueless_by_exception()`, `true`; otherwise if
76
  `v.valueless_by_exception()`, `false`; otherwise, if
77
  `v.index() > w.index()`, `true`; otherwise if `v.index() < w.index()`,
78
  `false`; otherwise `get<`i`>(v) >= get<`i`>(w)` with i being
79
  `v.index()`.
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ``` cpp
4
  template<class... Types>
5
  constexpr bool operator==(const variant<Types...>& v, const variant<Types...>& w);
6
  ```
7
 
8
+ *Mandates:* `get<`i`>(v) == get<`i`>(w)` is a valid expression that is
9
+ convertible to `bool`, for all i.
10
 
11
  *Returns:* If `v.index() != w.index()`, `false`; otherwise if
12
  `v.valueless_by_exception()`, `true`; otherwise
13
  `get<`i`>(v) == get<`i`>(w)` with i being `v.index()`.
14
 
15
  ``` cpp
16
  template<class... Types>
17
  constexpr bool operator!=(const variant<Types...>& v, const variant<Types...>& w);
18
  ```
19
 
20
+ *Mandates:* `get<`i`>(v) != get<`i`>(w)` is a valid expression that is
21
+ convertible to `bool`, for all i.
22
 
23
  *Returns:* If `v.index() != w.index()`, `true`; otherwise if
24
  `v.valueless_by_exception()`, `false`; otherwise
25
  `get<`i`>(v) != get<`i`>(w)` with i being `v.index()`.
26
 
27
  ``` cpp
28
  template<class... Types>
29
  constexpr bool operator<(const variant<Types...>& v, const variant<Types...>& w);
30
  ```
31
 
32
+ *Mandates:* `get<`i`>(v) < get<`i`>(w)` is a valid expression that is
33
+ convertible to `bool`, for all i.
34
 
35
  *Returns:* If `w.valueless_by_exception()`, `false`; otherwise if
36
  `v.valueless_by_exception()`, `true`; otherwise, if
37
  `v.index() < w.index()`, `true`; otherwise if `v.index() > w.index()`,
38
  `false`; otherwise `get<`i`>(v) < get<`i`>(w)` with i being `v.index()`.
 
40
  ``` cpp
41
  template<class... Types>
42
  constexpr bool operator>(const variant<Types...>& v, const variant<Types...>& w);
43
  ```
44
 
45
+ *Mandates:* `get<`i`>(v) > get<`i`>(w)` is a valid expression that is
46
+ convertible to `bool`, for all i.
47
 
48
  *Returns:* If `v.valueless_by_exception()`, `false`; otherwise if
49
  `w.valueless_by_exception()`, `true`; otherwise, if
50
  `v.index() > w.index()`, `true`; otherwise if `v.index() < w.index()`,
51
  `false`; otherwise `get<`i`>(v) > get<`i`>(w)` with i being `v.index()`.
 
53
  ``` cpp
54
  template<class... Types>
55
  constexpr bool operator<=(const variant<Types...>& v, const variant<Types...>& w);
56
  ```
57
 
58
+ *Mandates:* `get<`i`>(v) <= get<`i`>(w)` is a valid expression that is
59
+ convertible to `bool`, for all i.
60
 
61
  *Returns:* If `v.valueless_by_exception()`, `true`; otherwise if
62
  `w.valueless_by_exception()`, `false`; otherwise, if
63
  `v.index() < w.index()`, `true`; otherwise if `v.index() > w.index()`,
64
  `false`; otherwise `get<`i`>(v) <= get<`i`>(w)` with i being
 
67
  ``` cpp
68
  template<class... Types>
69
  constexpr bool operator>=(const variant<Types...>& v, const variant<Types...>& w);
70
  ```
71
 
72
+ *Mandates:* `get<`i`>(v) >= get<`i`>(w)` is a valid expression that is
73
+ convertible to `bool`, for all i.
74
 
75
  *Returns:* If `w.valueless_by_exception()`, `true`; otherwise if
76
  `v.valueless_by_exception()`, `false`; otherwise, if
77
  `v.index() > w.index()`, `true`; otherwise if `v.index() < w.index()`,
78
  `false`; otherwise `get<`i`>(v) >= get<`i`>(w)` with i being
79
  `v.index()`.
80
 
81
+ ``` cpp
82
+ template<class... Types> requires (three_way_comparable<Types> && ...)
83
+ constexpr common_comparison_category_t<compare_three_way_result_t<Types>...>
84
+ operator<=>(const variant<Types...>& v, const variant<Types...>& w);
85
+ ```
86
+
87
+ *Effects:* Equivalent to:
88
+
89
+ ``` cpp
90
+ if (v.valueless_by_exception() && w.valueless_by_exception())
91
+ return strong_ordering::equal;
92
+ if (v.valueless_by_exception()) return strong_ordering::less;
93
+ if (w.valueless_by_exception()) return strong_ordering::greater;
94
+ if (auto c = v.index() <=> w.index(); c != 0) return c;
95
+ return get<i>(v) <=> get<i>(w);
96
+ ```
97
+
98
+ with i being `v.index()`.
99
+