From Jason Turner

[string.view.comparison]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpemt1ud_e/{from.md → to.md} +99 -0
tmp/tmpemt1ud_e/{from.md → to.md} RENAMED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Table 
7
+ [[tab:string.view.comparison.overloads]].
8
+
9
+ **Table: Additional `basic_string_view` comparison overloads** <a id="tab:string.view.comparison.overloads">[tab: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
+
26
+
27
+ [*Example 1*:
28
+
29
+ A sample conforming implementation for `operator==` would be:
30
+
31
+ ``` cpp
32
+ template<class T> using __identity = decay_t<T>;
33
+ template<class charT, class traits>
34
+ constexpr bool operator==(basic_string_view<charT, traits> lhs,
35
+ basic_string_view<charT, traits> rhs) noexcept {
36
+ return lhs.compare(rhs) == 0;
37
+ }
38
+ template<class charT, class traits>
39
+ constexpr bool operator==(basic_string_view<charT, traits> lhs,
40
+ __identity<basic_string_view<charT, traits>> rhs) noexcept {
41
+ return lhs.compare(rhs) == 0;
42
+ }
43
+ template<class charT, class traits>
44
+ constexpr bool operator==(__identity<basic_string_view<charT, traits>> lhs,
45
+ basic_string_view<charT, traits> rhs) noexcept {
46
+ return lhs.compare(rhs) == 0;
47
+ }
48
+ ```
49
+
50
+ — *end example*]
51
+
52
+ ``` cpp
53
+ template<class charT, class traits>
54
+ constexpr bool operator==(basic_string_view<charT, traits> lhs,
55
+ basic_string_view<charT, traits> rhs) noexcept;
56
+ ```
57
+
58
+ *Returns:* `lhs.compare(rhs) == 0`.
59
+
60
+ ``` cpp
61
+ template<class charT, class traits>
62
+ constexpr bool operator!=(basic_string_view<charT, traits> lhs,
63
+ basic_string_view<charT, traits> rhs) noexcept;
64
+ ```
65
+
66
+ *Returns:* `lhs.compare(rhs) != 0`.
67
+
68
+ ``` cpp
69
+ template<class charT, class traits>
70
+ constexpr bool operator< (basic_string_view<charT, traits> lhs,
71
+ basic_string_view<charT, traits> rhs) noexcept;
72
+ ```
73
+
74
+ *Returns:* `lhs.compare(rhs) < 0`.
75
+
76
+ ``` cpp
77
+ template<class charT, class traits>
78
+ constexpr bool operator> (basic_string_view<charT, traits> lhs,
79
+ basic_string_view<charT, traits> rhs) noexcept;
80
+ ```
81
+
82
+ *Returns:* `lhs.compare(rhs) > 0`.
83
+
84
+ ``` cpp
85
+ template<class charT, class traits>
86
+ constexpr bool operator<=(basic_string_view<charT, traits> lhs,
87
+ basic_string_view<charT, traits> rhs) noexcept;
88
+ ```
89
+
90
+ *Returns:* `lhs.compare(rhs) <= 0`.
91
+
92
+ ``` cpp
93
+ template<class charT, class traits>
94
+ constexpr bool operator>=(basic_string_view<charT, traits> lhs,
95
+ basic_string_view<charT, traits> rhs) noexcept;
96
+ ```
97
+
98
+ *Returns:* `lhs.compare(rhs) >= 0`.
99
+