- tmp/tmp8p7b84dq/{from.md → to.md} +411 -86
tmp/tmp8p7b84dq/{from.md → to.md}
RENAMED
|
@@ -1,230 +1,555 @@
|
|
| 1 |
-
##
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
- If an algorithm’s template parameter is named `InputIterator`, the
|
| 7 |
-
template argument shall satisfy the requirements of an input
|
| 8 |
-
iterator ([[input.iterators]]).
|
| 9 |
-
- If an algorithm’s template parameter is named `ForwardIterator`, the
|
| 10 |
-
template argument shall satisfy the requirements of a forward
|
| 11 |
-
iterator ([[forward.iterators]]), and is required to have the
|
| 12 |
-
property that no exceptions are thrown from increment, assignment,
|
| 13 |
-
comparison, or indirection through valid iterators.
|
| 14 |
|
| 15 |
Unless otherwise specified, if an exception is thrown in the following
|
| 16 |
-
algorithms
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
-
template
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
```
|
| 23 |
|
| 24 |
-
*
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
subexpression ([[defns.const.subexpr]]) if `E` is an lvalue constant
|
| 29 |
-
subexpression.
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
``` cpp
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
```
|
| 37 |
|
| 38 |
*Effects:* Equivalent to:
|
| 39 |
|
| 40 |
``` cpp
|
| 41 |
for (; first != last; ++first)
|
| 42 |
-
::new (
|
| 43 |
-
|
| 44 |
```
|
| 45 |
|
| 46 |
``` cpp
|
| 47 |
-
template
|
| 48 |
-
|
| 49 |
```
|
| 50 |
|
| 51 |
*Effects:* Equivalent to:
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
for (; n > 0; (void)++first, --n)
|
| 55 |
-
::new (
|
| 56 |
-
typename iterator_traits<
|
| 57 |
return first;
|
| 58 |
```
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
``` cpp
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
```
|
| 66 |
|
| 67 |
*Effects:* Equivalent to:
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
for (; first != last; ++first)
|
| 71 |
-
::new (
|
| 72 |
-
|
| 73 |
```
|
| 74 |
|
| 75 |
``` cpp
|
| 76 |
-
template
|
| 77 |
-
|
| 78 |
```
|
| 79 |
|
| 80 |
*Effects:* Equivalent to:
|
| 81 |
|
| 82 |
``` cpp
|
| 83 |
for (; n > 0; (void)++first, --n)
|
| 84 |
-
::new (
|
| 85 |
-
typename iterator_traits<
|
| 86 |
return first;
|
| 87 |
```
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
ForwardIterator result);
|
| 95 |
```
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
for (; first != last; ++result, (void) ++first)
|
| 101 |
-
::new (
|
| 102 |
-
typename iterator_traits<
|
| 103 |
```
|
| 104 |
|
| 105 |
*Returns:* `result`.
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
```
|
| 112 |
|
| 113 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
``` cpp
|
| 116 |
for ( ; n > 0; ++result, (void) ++first, --n) {
|
| 117 |
-
::new (
|
| 118 |
-
typename iterator_traits<
|
| 119 |
}
|
| 120 |
```
|
| 121 |
|
| 122 |
*Returns:* `result`.
|
| 123 |
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
``` cpp
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
```
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
*Effects:* Equivalent to:
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
for (; first != last; (void)++result, ++first)
|
| 136 |
-
::new (
|
| 137 |
-
typename iterator_traits<
|
| 138 |
return result;
|
| 139 |
```
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
``` cpp
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
```
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
*Effects:* Equivalent to:
|
| 151 |
|
| 152 |
``` cpp
|
| 153 |
for (; n > 0; ++result, (void) ++first, --n)
|
| 154 |
-
::new (
|
| 155 |
-
typename iterator_traits<
|
| 156 |
return {first, result};
|
| 157 |
```
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
###
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
-
template
|
| 167 |
-
void uninitialized_fill(
|
| 168 |
-
const T& x);
|
| 169 |
```
|
| 170 |
|
| 171 |
-
*Effects:*
|
| 172 |
|
| 173 |
``` cpp
|
| 174 |
for (; first != last; ++first)
|
| 175 |
-
::new (
|
| 176 |
-
typename iterator_traits<
|
| 177 |
```
|
| 178 |
|
| 179 |
``` cpp
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
```
|
| 183 |
|
| 184 |
-
*Effects:*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
``` cpp
|
| 187 |
for (; n--; ++first)
|
| 188 |
-
::new (
|
| 189 |
-
typename iterator_traits<
|
| 190 |
return first;
|
| 191 |
```
|
| 192 |
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
``` cpp
|
| 196 |
template<class T>
|
| 197 |
-
void destroy_at(T* location);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
```
|
| 199 |
|
| 200 |
*Effects:* Equivalent to:
|
| 201 |
|
| 202 |
``` cpp
|
| 203 |
-
|
|
|
|
| 204 |
```
|
| 205 |
|
| 206 |
``` cpp
|
| 207 |
-
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
```
|
| 210 |
|
| 211 |
*Effects:* Equivalent to:
|
| 212 |
|
| 213 |
``` cpp
|
| 214 |
for (; first != last; ++first)
|
| 215 |
destroy_at(addressof(*first));
|
|
|
|
| 216 |
```
|
| 217 |
|
| 218 |
``` cpp
|
| 219 |
-
template
|
| 220 |
-
|
| 221 |
```
|
| 222 |
|
| 223 |
*Effects:* Equivalent to:
|
| 224 |
|
| 225 |
``` cpp
|
| 226 |
for (; n > 0; (void)++first, --n)
|
| 227 |
destroy_at(addressof(*first));
|
| 228 |
return first;
|
| 229 |
```
|
| 230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Specialized `<memory>` algorithms <a id="specialized.algorithms">[[specialized.algorithms]]</a>
|
| 2 |
|
| 3 |
+
The contents specified in this subclause [[specialized.algorithms]] are
|
| 4 |
+
declared in the header `<memory>`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
Unless otherwise specified, if an exception is thrown in the following
|
| 7 |
+
algorithms, objects constructed by a placement *new-expression*
|
| 8 |
+
[[expr.new]] are destroyed in an unspecified order before allowing the
|
| 9 |
+
exception to propagate.
|
| 10 |
|
| 11 |
+
[*Note 1*: When invoked on ranges of potentially-overlapping subobjects
|
| 12 |
+
[[intro.object]], the algorithms specified in this subclause
|
| 13 |
+
[[specialized.algorithms]] result in undefined behavior. — *end note*]
|
| 14 |
+
|
| 15 |
+
Some algorithms specified in this clause make use of the exposition-only
|
| 16 |
+
function `voidify`:
|
| 17 |
+
|
| 18 |
+
``` cpp
|
| 19 |
+
template<class T>
|
| 20 |
+
constexpr void* voidify(T& obj) noexcept {
|
| 21 |
+
return const_cast<void*>(static_cast<const volatile void*>(addressof(obj)));
|
| 22 |
+
}
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
### Special memory concepts <a id="special.mem.concepts">[[special.mem.concepts]]</a>
|
| 26 |
+
|
| 27 |
+
Some algorithms in this subclause are constrained with the following
|
| 28 |
+
exposition-only concepts:
|
| 29 |
+
|
| 30 |
+
``` cpp
|
| 31 |
+
template<class I>
|
| 32 |
+
concept no-throw-input-iterator = // exposition only
|
| 33 |
+
input_iterator<I> &&
|
| 34 |
+
is_lvalue_reference_v<iter_reference_t<I>> &&
|
| 35 |
+
same_as<remove_cvref_t<iter_reference_t<I>>, iter_value_t<I>>;
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
A type `I` models *`no-throw-input-iterator`* only if no exceptions are
|
| 39 |
+
thrown from increment, copy construction, move construction, copy
|
| 40 |
+
assignment, move assignment, or indirection through valid iterators.
|
| 41 |
+
|
| 42 |
+
[*Note 1*: This concept allows some `input_iterator`
|
| 43 |
+
[[iterator.concept.input]] operations to throw
|
| 44 |
+
exceptions. — *end note*]
|
| 45 |
+
|
| 46 |
+
``` cpp
|
| 47 |
+
template<class S, class I>
|
| 48 |
+
concept no-throw-sentinel = sentinel_for<S, I>; // exposition only
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Types `S` and `I` model *`no-throw-sentinel`* only if no exceptions are
|
| 52 |
+
thrown from copy construction, move construction, copy assignment, move
|
| 53 |
+
assignment, or comparisons between valid values of type `I` and `S`.
|
| 54 |
+
|
| 55 |
+
[*Note 2*: This concept allows some `sentinel_for`
|
| 56 |
+
[[iterator.concept.sentinel]] operations to throw
|
| 57 |
+
exceptions. — *end note*]
|
| 58 |
+
|
| 59 |
+
``` cpp
|
| 60 |
+
template<class R>
|
| 61 |
+
concept no-throw-input-range = // exposition only
|
| 62 |
+
range<R> &&
|
| 63 |
+
no-throw-input-iterator<iterator_t<R>> &&
|
| 64 |
+
no-throw-sentinel<sentinel_t<R>, iterator_t<R>>;
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
A type `R` models *`no-throw-input-range`* only if no exceptions are
|
| 68 |
+
thrown from calls to `ranges::begin` and `ranges::end` on an object of
|
| 69 |
+
type `R`.
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
+
template<class I>
|
| 73 |
+
concept no-throw-forward-iterator = // exposition only
|
| 74 |
+
no-throw-input-iterator<I> &&
|
| 75 |
+
forward_iterator<I> &&
|
| 76 |
+
no-throw-sentinel<I, I>;
|
| 77 |
```
|
| 78 |
|
| 79 |
+
[*Note 3*: This concept allows some `forward_iterator`
|
| 80 |
+
[[iterator.concept.forward]] operations to throw
|
| 81 |
+
exceptions. — *end note*]
|
| 82 |
+
|
| 83 |
+
``` cpp
|
| 84 |
+
template<class R>
|
| 85 |
+
concept no-throw-forward-range = // exposition only
|
| 86 |
+
no-throw-input-range<R> &&
|
| 87 |
+
no-throw-forward-iterator<iterator_t<R>>;
|
| 88 |
+
```
|
| 89 |
|
| 90 |
+
### `uninitialized_default_construct` <a id="uninitialized.construct.default">[[uninitialized.construct.default]]</a>
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
``` cpp
|
| 93 |
+
template<class NoThrowForwardIterator>
|
| 94 |
+
void uninitialized_default_construct(NoThrowForwardIterator first, NoThrowForwardIterator last);
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
*Effects:* Equivalent to:
|
| 98 |
+
|
| 99 |
+
``` cpp
|
| 100 |
+
for (; first != last; ++first)
|
| 101 |
+
::new (voidify(*first))
|
| 102 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type;
|
| 103 |
+
```
|
| 104 |
|
| 105 |
``` cpp
|
| 106 |
+
namespace ranges {
|
| 107 |
+
template<no-throw-forward-iterator I, no-throw-sentinel<I> S>
|
| 108 |
+
requires default_initializable<iter_value_t<I>>
|
| 109 |
+
I uninitialized_default_construct(I first, S last);
|
| 110 |
+
template<no-throw-forward-range R>
|
| 111 |
+
requires default_initializable<range_value_t<R>>
|
| 112 |
+
borrowed_iterator_t<R> uninitialized_default_construct(R&& r);
|
| 113 |
+
}
|
| 114 |
```
|
| 115 |
|
| 116 |
*Effects:* Equivalent to:
|
| 117 |
|
| 118 |
``` cpp
|
| 119 |
for (; first != last; ++first)
|
| 120 |
+
::new (voidify(*first)) remove_reference_t<iter_reference_t<I>>;
|
| 121 |
+
return first;
|
| 122 |
```
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
+
template<class NoThrowForwardIterator, class Size>
|
| 126 |
+
NoThrowForwardIterator uninitialized_default_construct_n(NoThrowForwardIterator first, Size n);
|
| 127 |
```
|
| 128 |
|
| 129 |
*Effects:* Equivalent to:
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
for (; n > 0; (void)++first, --n)
|
| 133 |
+
::new (voidify(*first))
|
| 134 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type;
|
| 135 |
return first;
|
| 136 |
```
|
| 137 |
|
| 138 |
+
``` cpp
|
| 139 |
+
namespace ranges {
|
| 140 |
+
template<no-throw-forward-iterator I>
|
| 141 |
+
requires default_initializable<iter_value_t<I>>
|
| 142 |
+
I uninitialized_default_construct_n(I first, iter_difference_t<I> n);
|
| 143 |
+
}
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
*Effects:* Equivalent to:
|
| 147 |
+
|
| 148 |
+
``` cpp
|
| 149 |
+
return uninitialized_default_construct(counted_iterator(first, n),
|
| 150 |
+
default_sentinel).base();
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
### `uninitialized_value_construct` <a id="uninitialized.construct.value">[[uninitialized.construct.value]]</a>
|
| 154 |
+
|
| 155 |
+
``` cpp
|
| 156 |
+
template<class NoThrowForwardIterator>
|
| 157 |
+
void uninitialized_value_construct(NoThrowForwardIterator first, NoThrowForwardIterator last);
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
*Effects:* Equivalent to:
|
| 161 |
+
|
| 162 |
+
``` cpp
|
| 163 |
+
for (; first != last; ++first)
|
| 164 |
+
::new (voidify(*first))
|
| 165 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type();
|
| 166 |
+
```
|
| 167 |
|
| 168 |
``` cpp
|
| 169 |
+
namespace ranges {
|
| 170 |
+
template<no-throw-forward-iterator I, no-throw-sentinel<I> S>
|
| 171 |
+
requires default_initializable<iter_value_t<I>>
|
| 172 |
+
I uninitialized_value_construct(I first, S last);
|
| 173 |
+
template<no-throw-forward-range R>
|
| 174 |
+
requires default_initializable<range_value_t<R>>
|
| 175 |
+
borrowed_iterator_t<R> uninitialized_value_construct(R&& r);
|
| 176 |
+
}
|
| 177 |
```
|
| 178 |
|
| 179 |
*Effects:* Equivalent to:
|
| 180 |
|
| 181 |
``` cpp
|
| 182 |
for (; first != last; ++first)
|
| 183 |
+
::new (voidify(*first)) remove_reference_t<iter_reference_t<I>>();
|
| 184 |
+
return first;
|
| 185 |
```
|
| 186 |
|
| 187 |
``` cpp
|
| 188 |
+
template<class NoThrowForwardIterator, class Size>
|
| 189 |
+
NoThrowForwardIterator uninitialized_value_construct_n(NoThrowForwardIterator first, Size n);
|
| 190 |
```
|
| 191 |
|
| 192 |
*Effects:* Equivalent to:
|
| 193 |
|
| 194 |
``` cpp
|
| 195 |
for (; n > 0; (void)++first, --n)
|
| 196 |
+
::new (voidify(*first))
|
| 197 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type();
|
| 198 |
return first;
|
| 199 |
```
|
| 200 |
|
| 201 |
+
``` cpp
|
| 202 |
+
namespace ranges {
|
| 203 |
+
template<no-throw-forward-iterator I>
|
| 204 |
+
requires default_initializable<iter_value_t<I>>
|
| 205 |
+
I uninitialized_value_construct_n(I first, iter_difference_t<I> n);
|
| 206 |
+
}
|
| 207 |
+
```
|
| 208 |
+
|
| 209 |
+
*Effects:* Equivalent to:
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
+
return uninitialized_value_construct(counted_iterator(first, n),
|
| 213 |
+
default_sentinel).base();
|
|
|
|
| 214 |
```
|
| 215 |
|
| 216 |
+
### `uninitialized_copy` <a id="uninitialized.copy">[[uninitialized.copy]]</a>
|
| 217 |
+
|
| 218 |
+
``` cpp
|
| 219 |
+
template<class InputIterator, class NoThrowForwardIterator>
|
| 220 |
+
NoThrowForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
|
| 221 |
+
NoThrowForwardIterator result);
|
| 222 |
+
```
|
| 223 |
+
|
| 224 |
+
*Preconditions:* `result`+\[0, `(last - first)`) does not overlap with
|
| 225 |
+
\[`first`, `last`).
|
| 226 |
+
|
| 227 |
+
*Effects:* Equivalent to:
|
| 228 |
|
| 229 |
``` cpp
|
| 230 |
for (; first != last; ++result, (void) ++first)
|
| 231 |
+
::new (voidify(*result))
|
| 232 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type(*first);
|
| 233 |
```
|
| 234 |
|
| 235 |
*Returns:* `result`.
|
| 236 |
|
| 237 |
``` cpp
|
| 238 |
+
namespace ranges {
|
| 239 |
+
template<input_iterator I, sentinel_for<I> S1,
|
| 240 |
+
no-throw-forward-iterator O, no-throw-sentinel<O> S2>
|
| 241 |
+
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 242 |
+
uninitialized_copy_result<I, O>
|
| 243 |
+
uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 244 |
+
template<input_range IR, no-throw-forward-range OR>
|
| 245 |
+
requires constructible_from<range_value_t<OR>, range_reference_t<IR>>
|
| 246 |
+
uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 247 |
+
uninitialized_copy(IR&& in_range, OR&& out_range);
|
| 248 |
+
}
|
| 249 |
```
|
| 250 |
|
| 251 |
+
*Preconditions:* \[`ofirst`, `olast`) does not overlap with \[`ifirst`,
|
| 252 |
+
`ilast`).
|
| 253 |
+
|
| 254 |
+
*Effects:* Equivalent to:
|
| 255 |
+
|
| 256 |
+
``` cpp
|
| 257 |
+
for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst) {
|
| 258 |
+
::new (voidify(*ofirst)) remove_reference_t<iter_reference_t<O>>(*ifirst);
|
| 259 |
+
}
|
| 260 |
+
return {std::move(ifirst), ofirst};
|
| 261 |
+
```
|
| 262 |
+
|
| 263 |
+
``` cpp
|
| 264 |
+
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
| 265 |
+
NoThrowForwardIterator uninitialized_copy_n(InputIterator first, Size n,
|
| 266 |
+
NoThrowForwardIterator result);
|
| 267 |
+
```
|
| 268 |
+
|
| 269 |
+
*Preconditions:* `result`+\[0, `n`) does not overlap with `first`+\[0,
|
| 270 |
+
`n`).
|
| 271 |
+
|
| 272 |
+
*Effects:* Equivalent to:
|
| 273 |
|
| 274 |
``` cpp
|
| 275 |
for ( ; n > 0; ++result, (void) ++first, --n) {
|
| 276 |
+
::new (voidify(*result))
|
| 277 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type(*first);
|
| 278 |
}
|
| 279 |
```
|
| 280 |
|
| 281 |
*Returns:* `result`.
|
| 282 |
|
| 283 |
+
``` cpp
|
| 284 |
+
namespace ranges {
|
| 285 |
+
template<input_iterator I, no-throw-forward-iterator O, no-throw-sentinel<O> S>
|
| 286 |
+
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 287 |
+
uninitialized_copy_n_result<I, O>
|
| 288 |
+
uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 289 |
+
}
|
| 290 |
+
```
|
| 291 |
+
|
| 292 |
+
*Preconditions:* \[`ofirst`, `olast`) does not overlap with
|
| 293 |
+
`ifirst`+\[0, `n`).
|
| 294 |
+
|
| 295 |
+
*Effects:* Equivalent to:
|
| 296 |
|
| 297 |
``` cpp
|
| 298 |
+
auto t = uninitialized_copy(counted_iterator(ifirst, n),
|
| 299 |
+
default_sentinel, ofirst, olast);
|
| 300 |
+
return {std::move(t.in).base(), t.out};
|
| 301 |
```
|
| 302 |
|
| 303 |
+
### `uninitialized_move` <a id="uninitialized.move">[[uninitialized.move]]</a>
|
| 304 |
+
|
| 305 |
+
``` cpp
|
| 306 |
+
template<class InputIterator, class NoThrowForwardIterator>
|
| 307 |
+
NoThrowForwardIterator uninitialized_move(InputIterator first, InputIterator last,
|
| 308 |
+
NoThrowForwardIterator result);
|
| 309 |
+
```
|
| 310 |
+
|
| 311 |
+
*Preconditions:* `result`+\[0, `(last - first)`) does not overlap with
|
| 312 |
+
\[`first`, `last`).
|
| 313 |
+
|
| 314 |
*Effects:* Equivalent to:
|
| 315 |
|
| 316 |
``` cpp
|
| 317 |
for (; first != last; (void)++result, ++first)
|
| 318 |
+
::new (voidify(*result))
|
| 319 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type(std::move(*first));
|
| 320 |
return result;
|
| 321 |
```
|
| 322 |
|
| 323 |
+
``` cpp
|
| 324 |
+
namespace ranges {
|
| 325 |
+
template<input_iterator I, sentinel_for<I> S1,
|
| 326 |
+
no-throw-forward-iterator O, no-throw-sentinel<O> S2>
|
| 327 |
+
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 328 |
+
uninitialized_move_result<I, O>
|
| 329 |
+
uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 330 |
+
template<input_range IR, no-throw-forward-range OR>
|
| 331 |
+
requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>
|
| 332 |
+
uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 333 |
+
uninitialized_move(IR&& in_range, OR&& out_range);
|
| 334 |
+
}
|
| 335 |
+
```
|
| 336 |
+
|
| 337 |
+
*Preconditions:* \[`ofirst`, `olast`) does not overlap with \[`ifirst`,
|
| 338 |
+
`ilast`).
|
| 339 |
+
|
| 340 |
+
*Effects:* Equivalent to:
|
| 341 |
|
| 342 |
``` cpp
|
| 343 |
+
for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst) {
|
| 344 |
+
::new (voidify(*ofirst))
|
| 345 |
+
remove_reference_t<iter_reference_t<O>>(ranges::iter_move(ifirst));
|
| 346 |
+
}
|
| 347 |
+
return {std::move(ifirst), ofirst};
|
| 348 |
```
|
| 349 |
|
| 350 |
+
[*Note 1*: If an exception is thrown, some objects in the range
|
| 351 |
+
\[`first`, `last`) are left in a valid, but unspecified
|
| 352 |
+
state. — *end note*]
|
| 353 |
+
|
| 354 |
+
``` cpp
|
| 355 |
+
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
| 356 |
+
pair<InputIterator, NoThrowForwardIterator>
|
| 357 |
+
uninitialized_move_n(InputIterator first, Size n, NoThrowForwardIterator result);
|
| 358 |
+
```
|
| 359 |
+
|
| 360 |
+
*Preconditions:* `result`+\[0, `n`) does not overlap with `first`+\[0,
|
| 361 |
+
`n`).
|
| 362 |
+
|
| 363 |
*Effects:* Equivalent to:
|
| 364 |
|
| 365 |
``` cpp
|
| 366 |
for (; n > 0; ++result, (void) ++first, --n)
|
| 367 |
+
::new (voidify(*result))
|
| 368 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type(std::move(*first));
|
| 369 |
return {first, result};
|
| 370 |
```
|
| 371 |
|
| 372 |
+
``` cpp
|
| 373 |
+
namespace ranges {
|
| 374 |
+
template<input_iterator I, no-throw-forward-iterator O, no-throw-sentinel<O> S>
|
| 375 |
+
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 376 |
+
uninitialized_move_n_result<I, O>
|
| 377 |
+
uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 378 |
+
}
|
| 379 |
+
```
|
| 380 |
+
|
| 381 |
+
*Preconditions:* \[`ofirst`, `olast`) does not overlap with
|
| 382 |
+
`ifirst`+\[0, `n`).
|
| 383 |
+
|
| 384 |
+
*Effects:* Equivalent to:
|
| 385 |
+
|
| 386 |
+
``` cpp
|
| 387 |
+
auto t = uninitialized_move(counted_iterator(ifirst, n),
|
| 388 |
+
default_sentinel, ofirst, olast);
|
| 389 |
+
return {std::move(t.in).base(), t.out};
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
[*Note 2*: If an exception is thrown, some objects in the range
|
| 393 |
+
`first`+\[0, `n`) are left in a valid but unspecified
|
| 394 |
+
state. — *end note*]
|
| 395 |
|
| 396 |
+
### `uninitialized_fill` <a id="uninitialized.fill">[[uninitialized.fill]]</a>
|
| 397 |
|
| 398 |
``` cpp
|
| 399 |
+
template<class NoThrowForwardIterator, class T>
|
| 400 |
+
void uninitialized_fill(NoThrowForwardIterator first, NoThrowForwardIterator last, const T& x);
|
|
|
|
| 401 |
```
|
| 402 |
|
| 403 |
+
*Effects:* Equivalent to:
|
| 404 |
|
| 405 |
``` cpp
|
| 406 |
for (; first != last; ++first)
|
| 407 |
+
::new (voidify(*first))
|
| 408 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type(x);
|
| 409 |
```
|
| 410 |
|
| 411 |
``` cpp
|
| 412 |
+
namespace ranges {
|
| 413 |
+
template<no-throw-forward-iterator I, no-throw-sentinel<I> S, class T>
|
| 414 |
+
requires constructible_from<iter_value_t<I>, const T&>
|
| 415 |
+
I uninitialized_fill(I first, S last, const T& x);
|
| 416 |
+
template<no-throw-forward-range R, class T>
|
| 417 |
+
requires constructible_from<range_value_t<R>, const T&>
|
| 418 |
+
borrowed_iterator_t<R> uninitialized_fill(R&& r, const T& x);
|
| 419 |
+
}
|
| 420 |
```
|
| 421 |
|
| 422 |
+
*Effects:* Equivalent to:
|
| 423 |
+
|
| 424 |
+
``` cpp
|
| 425 |
+
for (; first != last; ++first) {
|
| 426 |
+
::new (voidify(*first)) remove_reference_t<iter_reference_t<I>>(x);
|
| 427 |
+
}
|
| 428 |
+
return first;
|
| 429 |
+
```
|
| 430 |
+
|
| 431 |
+
``` cpp
|
| 432 |
+
template<class NoThrowForwardIterator, class Size, class T>
|
| 433 |
+
NoThrowForwardIterator uninitialized_fill_n(NoThrowForwardIterator first, Size n, const T& x);
|
| 434 |
+
```
|
| 435 |
+
|
| 436 |
+
*Effects:* Equivalent to:
|
| 437 |
|
| 438 |
``` cpp
|
| 439 |
for (; n--; ++first)
|
| 440 |
+
::new (voidify(*first))
|
| 441 |
+
typename iterator_traits<NoThrowForwardIterator>::value_type(x);
|
| 442 |
return first;
|
| 443 |
```
|
| 444 |
|
| 445 |
+
``` cpp
|
| 446 |
+
namespace ranges {
|
| 447 |
+
template<no-throw-forward-iterator I, class T>
|
| 448 |
+
requires constructible_from<iter_value_t<I>, const T&>
|
| 449 |
+
I uninitialized_fill_n(I first, iter_difference_t<I> n, const T& x);
|
| 450 |
+
}
|
| 451 |
+
```
|
| 452 |
+
|
| 453 |
+
*Effects:* Equivalent to:
|
| 454 |
+
|
| 455 |
+
``` cpp
|
| 456 |
+
return uninitialized_fill(counted_iterator(first, n), default_sentinel, x).base();
|
| 457 |
+
```
|
| 458 |
+
|
| 459 |
+
### `construct_at` <a id="specialized.construct">[[specialized.construct]]</a>
|
| 460 |
+
|
| 461 |
+
``` cpp
|
| 462 |
+
template<class T, class... Args>
|
| 463 |
+
constexpr T* construct_at(T* location, Args&&... args);
|
| 464 |
+
|
| 465 |
+
namespace ranges {
|
| 466 |
+
template<class T, class... Args>
|
| 467 |
+
constexpr T* construct_at(T* location, Args&&... args);
|
| 468 |
+
}
|
| 469 |
+
```
|
| 470 |
+
|
| 471 |
+
*Constraints:* The expression
|
| 472 |
+
`::new (declval<void*>()) T(declval<Args>()...)` is well-formed when
|
| 473 |
+
treated as an unevaluated operand.
|
| 474 |
+
|
| 475 |
+
*Effects:* Equivalent to:
|
| 476 |
+
|
| 477 |
+
``` cpp
|
| 478 |
+
return ::new (voidify(*location)) T(std::forward<Args>(args)...);
|
| 479 |
+
```
|
| 480 |
+
|
| 481 |
+
### `destroy` <a id="specialized.destroy">[[specialized.destroy]]</a>
|
| 482 |
|
| 483 |
``` cpp
|
| 484 |
template<class T>
|
| 485 |
+
constexpr void destroy_at(T* location);
|
| 486 |
+
namespace ranges {
|
| 487 |
+
template<destructible T>
|
| 488 |
+
constexpr void destroy_at(T* location) noexcept;
|
| 489 |
+
}
|
| 490 |
+
```
|
| 491 |
+
|
| 492 |
+
*Effects:*
|
| 493 |
+
|
| 494 |
+
- If `T` is an array type, equivalent to
|
| 495 |
+
`destroy(begin(*location), end(*location))`.
|
| 496 |
+
- Otherwise, equivalent to `location->T̃()`.
|
| 497 |
+
|
| 498 |
+
``` cpp
|
| 499 |
+
template<class NoThrowForwardIterator>
|
| 500 |
+
constexpr void destroy(NoThrowForwardIterator first, NoThrowForwardIterator last);
|
| 501 |
```
|
| 502 |
|
| 503 |
*Effects:* Equivalent to:
|
| 504 |
|
| 505 |
``` cpp
|
| 506 |
+
for (; first != last; ++first)
|
| 507 |
+
destroy_at(addressof(*first));
|
| 508 |
```
|
| 509 |
|
| 510 |
``` cpp
|
| 511 |
+
namespace ranges {
|
| 512 |
+
template<no-throw-input-iterator I, no-throw-sentinel<I> S>
|
| 513 |
+
requires destructible<iter_value_t<I>>
|
| 514 |
+
constexpr I destroy(I first, S last) noexcept;
|
| 515 |
+
template<no-throw-input-range R>
|
| 516 |
+
requires destructible<range_value_t<R>>
|
| 517 |
+
constexpr borrowed_iterator_t<R> destroy(R&& r) noexcept;
|
| 518 |
+
}
|
| 519 |
```
|
| 520 |
|
| 521 |
*Effects:* Equivalent to:
|
| 522 |
|
| 523 |
``` cpp
|
| 524 |
for (; first != last; ++first)
|
| 525 |
destroy_at(addressof(*first));
|
| 526 |
+
return first;
|
| 527 |
```
|
| 528 |
|
| 529 |
``` cpp
|
| 530 |
+
template<class NoThrowForwardIterator, class Size>
|
| 531 |
+
constexpr NoThrowForwardIterator destroy_n(NoThrowForwardIterator first, Size n);
|
| 532 |
```
|
| 533 |
|
| 534 |
*Effects:* Equivalent to:
|
| 535 |
|
| 536 |
``` cpp
|
| 537 |
for (; n > 0; (void)++first, --n)
|
| 538 |
destroy_at(addressof(*first));
|
| 539 |
return first;
|
| 540 |
```
|
| 541 |
|
| 542 |
+
``` cpp
|
| 543 |
+
namespace ranges {
|
| 544 |
+
template<no-throw-input-iterator I>
|
| 545 |
+
requires destructible<iter_value_t<I>>
|
| 546 |
+
constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept;
|
| 547 |
+
}
|
| 548 |
+
```
|
| 549 |
+
|
| 550 |
+
*Effects:* Equivalent to:
|
| 551 |
+
|
| 552 |
+
``` cpp
|
| 553 |
+
return destroy(counted_iterator(first, n), default_sentinel).base();
|
| 554 |
+
```
|
| 555 |
+
|