From Jason Turner

[string.view.comparison]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpqav0pvwb/{from.md → to.md} +8 -47
tmp/tmpqav0pvwb/{from.md → to.md} RENAMED
@@ -1,69 +1,30 @@
1
  ### Non-member comparison functions <a id="string.view.comparison">[[string.view.comparison]]</a>
2
 
3
- Let `S` be `basic_string_view<charT, traits>`, and `sv` be an instance
4
- of `S`. Implementations shall provide sufficient additional overloads
5
- marked `constexpr` and `noexcept` so that an object `t` with an implicit
6
- conversion to `S` can be compared according to
7
- [[string.view.comparison.overloads]].
8
-
9
- **Table: Additional `basic_string_view` comparison overloads** <a id="string.view.comparison.overloads">[string.view.comparison.overloads]</a>
10
-
11
- | Expression | Equivalent to |
12
- | ---------- | ------------- |
13
- | `t == sv` | `S(t) == sv` |
14
- | `sv == t` | `sv == S(t)` |
15
- | `t != sv` | `S(t) != sv` |
16
- | `sv != t` | `sv != S(t)` |
17
- | `t < sv` | `S(t) < sv` |
18
- | `sv < t` | `sv < S(t)` |
19
- | `t > sv` | `S(t) > sv` |
20
- | `sv > t` | `sv > S(t)` |
21
- | `t <= sv` | `S(t) <= sv` |
22
- | `sv <= t` | `sv <= S(t)` |
23
- | `t >= sv` | `S(t) >= sv` |
24
- | `sv >= t` | `sv >= S(t)` |
25
- | `t <=> sv` | `S(t) <=> sv` |
26
- | `sv <=> t` | `sv <=> S(t)` |
27
-
28
-
29
- [*Example 1*:
30
-
31
- A sample conforming implementation for `operator==` would be:
32
-
33
  ``` cpp
34
  template<class charT, class traits>
35
  constexpr bool operator==(basic_string_view<charT, traits> lhs,
36
- basic_string_view<charT, traits> rhs) noexcept {
37
- return lhs.compare(rhs) == 0;
38
- }
39
- template<class charT, class traits>
40
- constexpr bool operator==(basic_string_view<charT, traits> lhs,
41
- type_identity_t<basic_string_view<charT, traits>> rhs) noexcept {
42
- return lhs.compare(rhs) == 0;
43
- }
44
- ```
45
-
46
- — *end example*]
47
-
48
- ``` cpp
49
- template<class charT, class traits>
50
- constexpr bool operator==(basic_string_view<charT, traits> lhs,
51
- basic_string_view<charT, traits> rhs) noexcept;
52
  ```
53
 
54
  *Returns:* `lhs.compare(rhs) == 0`.
55
 
56
  ``` cpp
57
  template<class charT, class traits>
58
  constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
59
- \itcorr basic_string_view<charT, traits> rhs) noexcept;
60
  ```
61
 
62
  Let `R` denote the type `traits::comparison_category` if that
63
  *qualified-id* is valid and denotes a type [[temp.deduct]], otherwise
64
  `R` is `weak_ordering`.
65
 
66
  *Mandates:* `R` denotes a comparison category type [[cmp.categories]].
67
 
68
  *Returns:* `static_cast<R>(lhs.compare(rhs) <=> 0)`.
69
 
 
 
 
 
 
 
 
1
  ### Non-member comparison functions <a id="string.view.comparison">[[string.view.comparison]]</a>
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ``` cpp
4
  template<class charT, class traits>
5
  constexpr bool operator==(basic_string_view<charT, traits> lhs,
6
+ type_identity_t<basic_string_view<charT, traits>> rhs) noexcept;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  ```
8
 
9
  *Returns:* `lhs.compare(rhs) == 0`.
10
 
11
  ``` cpp
12
  template<class charT, class traits>
13
  constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
14
+ \itcorr type_identity_t<basic_string_view<charT, traits>> rhs) noexcept;
15
  ```
16
 
17
  Let `R` denote the type `traits::comparison_category` if that
18
  *qualified-id* is valid and denotes a type [[temp.deduct]], otherwise
19
  `R` is `weak_ordering`.
20
 
21
  *Mandates:* `R` denotes a comparison category type [[cmp.categories]].
22
 
23
  *Returns:* `static_cast<R>(lhs.compare(rhs) <=> 0)`.
24
 
25
+ [*Note 1*: The usage of `type_identity_t` as parameter ensures that an
26
+ object of type `basic_string_view<charT, traits>` can always be compared
27
+ with an object of a type `T` with an implicit conversion to
28
+ `basic_string_view<charT, traits>`, and vice versa, as per
29
+ [[over.match.oper]]. — *end note*]
30
+