From Jason Turner

[optional.comp.with.t]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp39qj1ssp/{from.md → to.md} +15 -14
tmp/tmp39qj1ssp/{from.md → to.md} RENAMED
@@ -7,115 +7,116 @@ template<class T, class U> constexpr bool operator==(const optional<T>& x, const
7
  *Mandates:* The expression `*x == v` is well-formed and its result is
8
  convertible to `bool`.
9
 
10
  [*Note 1*: `T` need not be *Cpp17EqualityComparable*. — *end note*]
11
 
12
- *Effects:* Equivalent to: `return bool(x) ? *x == v : false;`
13
 
14
  ``` cpp
15
  template<class T, class U> constexpr bool operator==(const T& v, const optional<U>& x);
16
  ```
17
 
18
  *Mandates:* The expression `v == *x` is well-formed and its result is
19
  convertible to `bool`.
20
 
21
- *Effects:* Equivalent to: `return bool(x) ? v == *x : false;`
22
 
23
  ``` cpp
24
  template<class T, class U> constexpr bool operator!=(const optional<T>& x, const U& v);
25
  ```
26
 
27
  *Mandates:* The expression `*x != v` is well-formed and its result is
28
  convertible to `bool`.
29
 
30
- *Effects:* Equivalent to: `return bool(x) ? *x != v : true;`
31
 
32
  ``` cpp
33
  template<class T, class U> constexpr bool operator!=(const T& v, const optional<U>& x);
34
  ```
35
 
36
  *Mandates:* The expression `v != *x` is well-formed and its result is
37
  convertible to `bool`.
38
 
39
- *Effects:* Equivalent to: `return bool(x) ? v != *x : true;`
40
 
41
  ``` cpp
42
  template<class T, class U> constexpr bool operator<(const optional<T>& x, const U& v);
43
  ```
44
 
45
  *Mandates:* The expression `*x < v` is well-formed and its result is
46
  convertible to `bool`.
47
 
48
- *Effects:* Equivalent to: `return bool(x) ? *x < v : true;`
49
 
50
  ``` cpp
51
  template<class T, class U> constexpr bool operator<(const T& v, const optional<U>& x);
52
  ```
53
 
54
  *Mandates:* The expression `v < *x` is well-formed and its result is
55
  convertible to `bool`.
56
 
57
- *Effects:* Equivalent to: `return bool(x) ? v < *x : false;`
58
 
59
  ``` cpp
60
  template<class T, class U> constexpr bool operator>(const optional<T>& x, const U& v);
61
  ```
62
 
63
  *Mandates:* The expression `*x > v` is well-formed and its result is
64
  convertible to `bool`.
65
 
66
- *Effects:* Equivalent to: `return bool(x) ? *x > v : false;`
67
 
68
  ``` cpp
69
  template<class T, class U> constexpr bool operator>(const T& v, const optional<U>& x);
70
  ```
71
 
72
  *Mandates:* The expression `v > *x` is well-formed and its result is
73
  convertible to `bool`.
74
 
75
- *Effects:* Equivalent to: `return bool(x) ? v > *x : true;`
76
 
77
  ``` cpp
78
  template<class T, class U> constexpr bool operator<=(const optional<T>& x, const U& v);
79
  ```
80
 
81
  *Mandates:* The expression `*x <= v` is well-formed and its result is
82
  convertible to `bool`.
83
 
84
- *Effects:* Equivalent to: `return bool(x) ? *x <= v : true;`
85
 
86
  ``` cpp
87
  template<class T, class U> constexpr bool operator<=(const T& v, const optional<U>& x);
88
  ```
89
 
90
  *Mandates:* The expression `v <= *x` is well-formed and its result is
91
  convertible to `bool`.
92
 
93
- *Effects:* Equivalent to: `return bool(x) ? v <= *x : false;`
94
 
95
  ``` cpp
96
  template<class T, class U> constexpr bool operator>=(const optional<T>& x, const U& v);
97
  ```
98
 
99
  *Mandates:* The expression `*x >= v` is well-formed and its result is
100
  convertible to `bool`.
101
 
102
- *Effects:* Equivalent to: `return bool(x) ? *x >= v : false;`
103
 
104
  ``` cpp
105
  template<class T, class U> constexpr bool operator>=(const T& v, const optional<U>& x);
106
  ```
107
 
108
  *Mandates:* The expression `v >= *x` is well-formed and its result is
109
  convertible to `bool`.
110
 
111
- *Effects:* Equivalent to: `return bool(x) ? v >= *x : true;`
112
 
113
  ``` cpp
114
- template<class T, three_way_comparable_with<T> U>
 
115
  constexpr compare_three_way_result_t<T, U>
116
  operator<=>(const optional<T>& x, const U& v);
117
  ```
118
 
119
  *Effects:* Equivalent to:
120
- `return bool(x) ? *x <=> v : strong_ordering::less;`
121
 
 
7
  *Mandates:* The expression `*x == v` is well-formed and its result is
8
  convertible to `bool`.
9
 
10
  [*Note 1*: `T` need not be *Cpp17EqualityComparable*. — *end note*]
11
 
12
+ *Effects:* Equivalent to: `return x.has_value() ? *x == v : false;`
13
 
14
  ``` cpp
15
  template<class T, class U> constexpr bool operator==(const T& v, const optional<U>& x);
16
  ```
17
 
18
  *Mandates:* The expression `v == *x` is well-formed and its result is
19
  convertible to `bool`.
20
 
21
+ *Effects:* Equivalent to: `return x.has_value() ? v == *x : false;`
22
 
23
  ``` cpp
24
  template<class T, class U> constexpr bool operator!=(const optional<T>& x, const U& v);
25
  ```
26
 
27
  *Mandates:* The expression `*x != v` is well-formed and its result is
28
  convertible to `bool`.
29
 
30
+ *Effects:* Equivalent to: `return x.has_value() ? *x != v : true;`
31
 
32
  ``` cpp
33
  template<class T, class U> constexpr bool operator!=(const T& v, const optional<U>& x);
34
  ```
35
 
36
  *Mandates:* The expression `v != *x` is well-formed and its result is
37
  convertible to `bool`.
38
 
39
+ *Effects:* Equivalent to: `return x.has_value() ? v != *x : true;`
40
 
41
  ``` cpp
42
  template<class T, class U> constexpr bool operator<(const optional<T>& x, const U& v);
43
  ```
44
 
45
  *Mandates:* The expression `*x < v` is well-formed and its result is
46
  convertible to `bool`.
47
 
48
+ *Effects:* Equivalent to: `return x.has_value() ? *x < v : true;`
49
 
50
  ``` cpp
51
  template<class T, class U> constexpr bool operator<(const T& v, const optional<U>& x);
52
  ```
53
 
54
  *Mandates:* The expression `v < *x` is well-formed and its result is
55
  convertible to `bool`.
56
 
57
+ *Effects:* Equivalent to: `return x.has_value() ? v < *x : false;`
58
 
59
  ``` cpp
60
  template<class T, class U> constexpr bool operator>(const optional<T>& x, const U& v);
61
  ```
62
 
63
  *Mandates:* The expression `*x > v` is well-formed and its result is
64
  convertible to `bool`.
65
 
66
+ *Effects:* Equivalent to: `return x.has_value() ? *x > v : false;`
67
 
68
  ``` cpp
69
  template<class T, class U> constexpr bool operator>(const T& v, const optional<U>& x);
70
  ```
71
 
72
  *Mandates:* The expression `v > *x` is well-formed and its result is
73
  convertible to `bool`.
74
 
75
+ *Effects:* Equivalent to: `return x.has_value() ? v > *x : true;`
76
 
77
  ``` cpp
78
  template<class T, class U> constexpr bool operator<=(const optional<T>& x, const U& v);
79
  ```
80
 
81
  *Mandates:* The expression `*x <= v` is well-formed and its result is
82
  convertible to `bool`.
83
 
84
+ *Effects:* Equivalent to: `return x.has_value() ? *x <= v : true;`
85
 
86
  ``` cpp
87
  template<class T, class U> constexpr bool operator<=(const T& v, const optional<U>& x);
88
  ```
89
 
90
  *Mandates:* The expression `v <= *x` is well-formed and its result is
91
  convertible to `bool`.
92
 
93
+ *Effects:* Equivalent to: `return x.has_value() ? v <= *x : false;`
94
 
95
  ``` cpp
96
  template<class T, class U> constexpr bool operator>=(const optional<T>& x, const U& v);
97
  ```
98
 
99
  *Mandates:* The expression `*x >= v` is well-formed and its result is
100
  convertible to `bool`.
101
 
102
+ *Effects:* Equivalent to: `return x.has_value() ? *x >= v : false;`
103
 
104
  ``` cpp
105
  template<class T, class U> constexpr bool operator>=(const T& v, const optional<U>& x);
106
  ```
107
 
108
  *Mandates:* The expression `v >= *x` is well-formed and its result is
109
  convertible to `bool`.
110
 
111
+ *Effects:* Equivalent to: `return x.has_value() ? v >= *x : true;`
112
 
113
  ``` cpp
114
+ template<class T, class U>
115
+ requires (!is-derived-from-optional<U>) && three_way_comparable_with<T, U>
116
  constexpr compare_three_way_result_t<T, U>
117
  operator<=>(const optional<T>& x, const U& v);
118
  ```
119
 
120
  *Effects:* Equivalent to:
121
+ `return x.has_value() ? *x <=> v : strong_ordering::less;`
122