From Jason Turner

[string.capacity]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfi_lghiu/{from.md → to.md} +35 -0
tmp/tmpfi_lghiu/{from.md → to.md} RENAMED
@@ -32,10 +32,45 @@ constexpr void resize(size_type n, charT c);
32
  constexpr void resize(size_type n);
33
  ```
34
 
35
  *Effects:* Equivalent to `resize(n, charT())`.
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ``` cpp
38
  constexpr size_type capacity() const noexcept;
39
  ```
40
 
41
  *Returns:* The size of the allocated storage in the string.
 
32
  constexpr void resize(size_type n);
33
  ```
34
 
35
  *Effects:* Equivalent to `resize(n, charT())`.
36
 
37
+ ``` cpp
38
+ template<class Operation> constexpr void resize_and_overwrite(size_type n, Operation op);
39
+ ```
40
+
41
+ Let
42
+
43
+ - `o = size()` before the call to `resize_and_overwrite`.
44
+ - `k` be `min(o, n)`.
45
+ - `p` be a value of type `charT*` or `charT* const`, such that the range
46
+ \[`p`, `p + n`\] is valid and `this->compare(0, k, p, k) == 0` is
47
+ `true` before the call. The values in the range \[`p + k`, `p + n`\]
48
+ may be indeterminate [[basic.indet]].
49
+ - `m` be a value of type `size_type` or `const size_type` equal to `n`.
50
+ - *`OP`* be the expression `std::move(op)(p, m)`.
51
+ - `r` = *`OP`*.
52
+
53
+ *Mandates:* *`OP`* has an integer-like type [[iterator.concept.winc]].
54
+
55
+ *Preconditions:*
56
+
57
+ - *`OP`* does not throw an exception or modify `p` or `m`.
58
+ - `r` ≥ 0.
59
+ - `r` ≤ `m`.
60
+ - After evaluating *`OP`* there are no indeterminate values in the range
61
+ \[`p`, `p + r`).
62
+
63
+ *Effects:* Evaluates *`OP`*, replaces the contents of `*this` with
64
+ \[`p`, `p + r`), and invalidates all pointers and references to the
65
+ range \[`p`, `p + n`\].
66
+
67
+ *Recommended practice:* Implementations should avoid unnecessary copies
68
+ and allocations by, for example, making `p` a pointer into internal
69
+ storage and by restoring `*(p + r)` to `charT()` after evaluating
70
+ *`OP`*.
71
+
72
  ``` cpp
73
  constexpr size_type capacity() const noexcept;
74
  ```
75
 
76
  *Returns:* The size of the allocated storage in the string.