tmp/tmptaeaxgum/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
### `basic_string` capacity <a id="string.capacity">[[string.capacity]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
size_type size() const noexcept;
|
| 5 |
```
|
| 6 |
|
|
@@ -17,20 +17,19 @@ size_type length() const noexcept;
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
size_type max_size() const noexcept;
|
| 20 |
```
|
| 21 |
|
| 22 |
-
*Returns:* The
|
|
|
|
| 23 |
|
| 24 |
*Complexity:* Constant time.
|
| 25 |
|
| 26 |
``` cpp
|
| 27 |
void resize(size_type n, charT c);
|
| 28 |
```
|
| 29 |
|
| 30 |
-
*Requires:* `n <= max_size()`
|
| 31 |
-
|
| 32 |
*Throws:* `length_error` if `n > max_size()`.
|
| 33 |
|
| 34 |
*Effects:* Alters the length of the string designated by `*this` as
|
| 35 |
follows:
|
| 36 |
|
|
@@ -44,11 +43,11 @@ follows:
|
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
void resize(size_type n);
|
| 47 |
```
|
| 48 |
|
| 49 |
-
*Effects:* `resize(n,charT())`.
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
size_type capacity() const noexcept;
|
| 53 |
```
|
| 54 |
|
|
@@ -61,24 +60,37 @@ void reserve(size_type res_arg=0);
|
|
| 61 |
The member function `reserve()` is a directive that informs a
|
| 62 |
`basic_string` object of a planned change in size, so that it can manage
|
| 63 |
the storage allocation accordingly.
|
| 64 |
|
| 65 |
*Effects:* After `reserve()`, `capacity()` is greater or equal to the
|
| 66 |
-
argument of `reserve`.
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
request.
|
|
|
|
|
|
|
| 70 |
|
| 71 |
*Throws:* `length_error` if `res_arg > max_size()`.[^4]
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
void shrink_to_fit();
|
| 75 |
```
|
| 76 |
|
| 77 |
-
*
|
| 78 |
-
`capacity()` to `size()`.
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
``` cpp
|
| 82 |
void clear() noexcept;
|
| 83 |
```
|
| 84 |
|
|
|
|
| 1 |
+
#### `basic_string` capacity <a id="string.capacity">[[string.capacity]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
size_type size() const noexcept;
|
| 5 |
```
|
| 6 |
|
|
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
size_type max_size() const noexcept;
|
| 20 |
```
|
| 21 |
|
| 22 |
+
*Returns:* The largest possible number of char-like objects that can be
|
| 23 |
+
stored in a `basic_string`.
|
| 24 |
|
| 25 |
*Complexity:* Constant time.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
void resize(size_type n, charT c);
|
| 29 |
```
|
| 30 |
|
|
|
|
|
|
|
| 31 |
*Throws:* `length_error` if `n > max_size()`.
|
| 32 |
|
| 33 |
*Effects:* Alters the length of the string designated by `*this` as
|
| 34 |
follows:
|
| 35 |
|
|
|
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
void resize(size_type n);
|
| 46 |
```
|
| 47 |
|
| 48 |
+
*Effects:* As if by `resize(n, charT())`.
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
size_type capacity() const noexcept;
|
| 52 |
```
|
| 53 |
|
|
|
|
| 60 |
The member function `reserve()` is a directive that informs a
|
| 61 |
`basic_string` object of a planned change in size, so that it can manage
|
| 62 |
the storage allocation accordingly.
|
| 63 |
|
| 64 |
*Effects:* After `reserve()`, `capacity()` is greater or equal to the
|
| 65 |
+
argument of `reserve`.
|
| 66 |
+
|
| 67 |
+
[*Note 1*: Calling `reserve()` with a `res_arg` argument less than
|
| 68 |
+
`capacity()` is in effect a non-binding shrink request. A call with
|
| 69 |
+
`res_arg <= size()` is in effect a non-binding shrink-to-fit
|
| 70 |
+
request. — *end note*]
|
| 71 |
|
| 72 |
*Throws:* `length_error` if `res_arg > max_size()`.[^4]
|
| 73 |
|
| 74 |
``` cpp
|
| 75 |
void shrink_to_fit();
|
| 76 |
```
|
| 77 |
|
| 78 |
+
*Effects:* `shrink_to_fit` is a non-binding request to reduce
|
| 79 |
+
`capacity()` to `size()`.
|
| 80 |
+
|
| 81 |
+
[*Note 2*: The request is non-binding to allow latitude for
|
| 82 |
+
implementation-specific optimizations. — *end note*]
|
| 83 |
+
|
| 84 |
+
It does not increase `capacity()`, but may reduce `capacity()` by
|
| 85 |
+
causing reallocation.
|
| 86 |
+
|
| 87 |
+
*Complexity:* Linear in the size of the sequence.
|
| 88 |
+
|
| 89 |
+
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 90 |
+
iterators referring to the elements in the sequence as well as the
|
| 91 |
+
past-the-end iterator. If no reallocation happens, they remain valid.
|
| 92 |
|
| 93 |
``` cpp
|
| 94 |
void clear() noexcept;
|
| 95 |
```
|
| 96 |
|