From Jason Turner

[string.view.ops]

Diff to HTML by rtfpessoa

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