From Jason Turner

[string.compare]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1v3jrzq1/{from.md → to.md} +95 -0
tmp/tmp1v3jrzq1/{from.md → to.md} RENAMED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### `basic_string::compare` <a id="string.compare">[[string.compare]]</a>
2
+
3
+ ``` cpp
4
+ int compare(basic_string_view<charT, traits> sv) const noexcept;
5
+ ```
6
+
7
+ *Effects:* Determines the effective length `rlen` of the strings to
8
+ compare as the smaller of `size()` and `sv.size()`. The function then
9
+ compares the two strings by calling
10
+ `traits::compare(data(), sv.data(), rlen)`.
11
+
12
+ *Returns:* The nonzero result if the result of the comparison is
13
+ nonzero. Otherwise, returns a value as indicated in
14
+ Table  [[tab:strings.compare]].
15
+
16
+ **Table: `compare()` results** <a id="tab:strings.compare">[tab:strings.compare]</a>
17
+
18
+ | Condition | Return Value |
19
+ | --------------------- | ------------ |
20
+ | `size() < sv.size()` | `< 0` |
21
+ | `size() == sv.size()` | ` 0` |
22
+ | `size() > sv.size()` | `> 0` |
23
+
24
+ ``` cpp
25
+ int compare(size_type pos1, size_type n1, basic_string_view<charT, traits> sv) const;
26
+ ```
27
+
28
+ *Effects:* Equivalent to:
29
+
30
+ ``` cpp
31
+ return basic_string_view<charT, traits>(data(), size()).substr(pos1, n1).compare(sv);
32
+ ```
33
+
34
+ ``` cpp
35
+ template<class T>
36
+ int compare(size_type pos1, size_type n1, const T& t,
37
+ size_type pos2, size_type n2 = npos) const;
38
+ ```
39
+
40
+ *Effects:* Equivalent to:
41
+
42
+ ``` cpp
43
+ basic_string_view<charT, traits> sv = t;
44
+ return basic_string_view<charT, traits>(
45
+ data(), size()).substr(pos1, n1).compare(sv.substr(pos2, n2));
46
+ ```
47
+
48
+ *Remarks:* This function shall not participate in overload resolution
49
+ unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
50
+ `true` and `is_convertible_v<const T&, const charT*>` is `false`.
51
+
52
+ ``` cpp
53
+ int compare(const basic_string& str) const noexcept;
54
+ ```
55
+
56
+ *Effects:* Equivalent to:
57
+ `return compare(basic_string_view<charT, traits>(str));`
58
+
59
+ ``` cpp
60
+ int compare(size_type pos1, size_type n1, const basic_string& str) const;
61
+ ```
62
+
63
+ *Effects:* Equivalent to:
64
+ `return compare(pos1, n1, basic_string_view<charT, traits>(str));`
65
+
66
+ ``` cpp
67
+ int compare(size_type pos1, size_type n1,
68
+ const basic_string& str,
69
+ size_type pos2, size_type n2 = npos) const;
70
+ ```
71
+
72
+ *Effects:* Equivalent to:
73
+
74
+ ``` cpp
75
+ return compare(pos1, n1, basic_string_view<charT, traits>(str), pos2, n2);
76
+ ```
77
+
78
+ ``` cpp
79
+ int compare(const charT* s) const;
80
+ ```
81
+
82
+ *Returns:* `compare(basic_string(s))`.
83
+
84
+ ``` cpp
85
+ int compare(size_type pos, size_type n1, const charT* s) const;
86
+ ```
87
+
88
+ *Returns:* `basic_string(*this, pos, n1).compare(basic_string(s))`.
89
+
90
+ ``` cpp
91
+ int compare(size_type pos, size_type n1, const charT* s, size_type n2) const;
92
+ ```
93
+
94
+ *Returns:* `basic_string(*this, pos, n1).compare(basic_string(s, n2))`.
95
+