tmp/tmp_nuk6vap/{from.md → to.md}
RENAMED
|
@@ -9,10 +9,12 @@ requiring reallocation.
|
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
void reserve(size_type n);
|
| 12 |
```
|
| 13 |
|
|
|
|
|
|
|
| 14 |
*Effects:* A directive that informs a `vector` of a planned change in
|
| 15 |
size, so that it can manage the storage allocation accordingly. After
|
| 16 |
`reserve()`, `capacity()` is greater or equal to the argument of
|
| 17 |
`reserve` if reallocation happens; and equal to the previous value of
|
| 18 |
`capacity()` otherwise. Reallocation happens at this point if and only
|
|
@@ -24,22 +26,28 @@ non-`CopyInsertable` type, there are no effects.
|
|
| 24 |
most linear time in the size of the sequence.
|
| 25 |
|
| 26 |
*Throws:* `length_error` if `n > max_size()`.[^4]
|
| 27 |
|
| 28 |
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 29 |
-
iterators referring to the elements in the sequence.
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
``` cpp
|
| 35 |
void shrink_to_fit();
|
| 36 |
```
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
*Remarks:* `shrink_to_fit` is a non-binding request to reduce
|
| 39 |
`capacity()` to `size()`. The request is non-binding to allow latitude
|
| 40 |
-
for implementation-specific optimizations.
|
|
|
|
|
|
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
void swap(vector& x);
|
| 44 |
```
|
| 45 |
|
|
@@ -50,29 +58,27 @@ of `x`.
|
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
void resize(size_type sz);
|
| 53 |
```
|
| 54 |
|
| 55 |
-
*Effects:* If `sz <= size()`, equivalent to
|
| 56 |
-
`
|
| 57 |
-
|
| 58 |
|
| 59 |
-
*Requires:* `T` shall be `
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
void resize(size_type sz, const T& c);
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
*Effects:*
|
| 66 |
-
|
| 67 |
-
``` cpp
|
| 68 |
-
if (sz > size())
|
| 69 |
-
insert(end(), sz-size(), c);
|
| 70 |
-
else if (sz < size())
|
| 71 |
-
erase(begin()+sz, end());
|
| 72 |
-
else
|
| 73 |
-
; // do nothing
|
| 74 |
-
```
|
| 75 |
-
|
| 76 |
-
*Requires:* If an exception is thrown other than by the move constructor
|
| 77 |
of a non-`CopyInsertable` `T` there are no effects.
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
void reserve(size_type n);
|
| 12 |
```
|
| 13 |
|
| 14 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 15 |
+
|
| 16 |
*Effects:* A directive that informs a `vector` of a planned change in
|
| 17 |
size, so that it can manage the storage allocation accordingly. After
|
| 18 |
`reserve()`, `capacity()` is greater or equal to the argument of
|
| 19 |
`reserve` if reallocation happens; and equal to the previous value of
|
| 20 |
`capacity()` otherwise. Reallocation happens at this point if and only
|
|
|
|
| 26 |
most linear time in the size of the sequence.
|
| 27 |
|
| 28 |
*Throws:* `length_error` if `n > max_size()`.[^4]
|
| 29 |
|
| 30 |
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 31 |
+
iterators referring to the elements in the sequence. No reallocation
|
| 32 |
+
shall take place during insertions that happen after a call to
|
| 33 |
+
`reserve()` until the time when an insertion would make the size of the
|
| 34 |
+
vector greater than the value of `capacity()`.
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
void shrink_to_fit();
|
| 38 |
```
|
| 39 |
|
| 40 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 41 |
+
|
| 42 |
+
*Complexity:* Linear in the size of the sequence.
|
| 43 |
+
|
| 44 |
*Remarks:* `shrink_to_fit` is a non-binding request to reduce
|
| 45 |
`capacity()` to `size()`. The request is non-binding to allow latitude
|
| 46 |
+
for implementation-specific optimizations. If an exception is thrown
|
| 47 |
+
other than by the move constructor of a non-`CopyInsertable` `T` there
|
| 48 |
+
are no effects.
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
void swap(vector& x);
|
| 52 |
```
|
| 53 |
|
|
|
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
void resize(size_type sz);
|
| 61 |
```
|
| 62 |
|
| 63 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 64 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()`
|
| 65 |
+
default-inserted elements to the sequence.
|
| 66 |
|
| 67 |
+
*Requires:* `T` shall be `MoveInsertable` and `DefaultInsertable` into
|
| 68 |
+
`*this`.
|
| 69 |
|
| 70 |
+
*Remarks:* If an exception is thrown other than by the move constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
of a non-`CopyInsertable` `T` there are no effects.
|
| 72 |
|
| 73 |
+
``` cpp
|
| 74 |
+
void resize(size_type sz, const T& c);
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 78 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()` copies of
|
| 79 |
+
`c` to the sequence.
|
| 80 |
+
|
| 81 |
+
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
| 82 |
+
|
| 83 |
+
*Remarks:* If an exception is thrown there are no effects.
|
| 84 |
+
|