- tmp/tmp6m104vf0/{from.md → to.md} +265 -204
tmp/tmp6m104vf0/{from.md → to.md}
RENAMED
|
@@ -4,13 +4,13 @@
|
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
namespace std {
|
| 7 |
template<class T> class valarray {
|
| 8 |
public:
|
| 9 |
-
|
| 10 |
|
| 11 |
-
// [valarray.cons] construct/destroy
|
| 12 |
valarray();
|
| 13 |
explicit valarray(size_t);
|
| 14 |
valarray(const T&, size_t);
|
| 15 |
valarray(const T*, size_t);
|
| 16 |
valarray(const valarray&);
|
|
@@ -20,149 +20,151 @@ namespace std {
|
|
| 20 |
valarray(const mask_array<T>&);
|
| 21 |
valarray(const indirect_array<T>&);
|
| 22 |
valarray(initializer_list<T>);
|
| 23 |
~valarray();
|
| 24 |
|
| 25 |
-
// [valarray.assign] assignment
|
| 26 |
-
valarray
|
| 27 |
-
valarray
|
| 28 |
valarray& operator=(initializer_list<T>);
|
| 29 |
-
valarray
|
| 30 |
-
valarray
|
| 31 |
-
valarray
|
| 32 |
-
valarray
|
| 33 |
-
valarray
|
| 34 |
|
| 35 |
-
// [valarray.access] element access
|
| 36 |
const T& operator[](size_t) const;
|
| 37 |
T& operator[](size_t);
|
| 38 |
|
| 39 |
-
// [valarray.sub] subset operations
|
| 40 |
-
valarray
|
| 41 |
slice_array<T> operator[](slice);
|
| 42 |
-
valarray
|
| 43 |
gslice_array<T> operator[](const gslice&);
|
| 44 |
-
valarray
|
| 45 |
mask_array<T> operator[](const valarray<bool>&);
|
| 46 |
-
valarray
|
| 47 |
indirect_array<T> operator[](const valarray<size_t>&);
|
| 48 |
|
| 49 |
-
// [valarray.unary] unary operators
|
| 50 |
-
valarray
|
| 51 |
-
valarray
|
| 52 |
-
valarray
|
| 53 |
valarray<bool> operator!() const;
|
| 54 |
|
| 55 |
-
// [valarray.cassign]
|
| 56 |
-
valarray
|
| 57 |
-
valarray
|
| 58 |
-
valarray
|
| 59 |
-
valarray
|
| 60 |
-
valarray
|
| 61 |
-
valarray
|
| 62 |
-
valarray
|
| 63 |
-
valarray
|
| 64 |
-
valarray
|
| 65 |
-
valarray
|
| 66 |
|
| 67 |
-
valarray
|
| 68 |
-
valarray
|
| 69 |
-
valarray
|
| 70 |
-
valarray
|
| 71 |
-
valarray
|
| 72 |
-
valarray
|
| 73 |
-
valarray
|
| 74 |
-
valarray
|
| 75 |
-
valarray
|
| 76 |
-
valarray
|
| 77 |
|
| 78 |
-
// [valarray.members] member functions
|
| 79 |
void swap(valarray&) noexcept;
|
| 80 |
|
| 81 |
size_t size() const;
|
| 82 |
|
| 83 |
T sum() const;
|
| 84 |
T min() const;
|
| 85 |
T max() const;
|
| 86 |
|
| 87 |
-
valarray
|
| 88 |
-
valarray
|
| 89 |
-
valarray
|
| 90 |
-
valarray
|
| 91 |
void resize(size_t sz, T c = T());
|
| 92 |
};
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
```
|
| 95 |
|
| 96 |
The class template `valarray<T>` is a one-dimensional smart array, with
|
| 97 |
elements numbered sequentially from zero. It is a representation of the
|
| 98 |
-
mathematical concept of an ordered set of values.
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
the
|
|
|
|
|
|
|
| 102 |
|
| 103 |
An implementation is permitted to qualify any of the functions declared
|
| 104 |
in `<valarray>` as `inline`.
|
| 105 |
|
| 106 |
#### `valarray` constructors <a id="valarray.cons">[[valarray.cons]]</a>
|
| 107 |
|
| 108 |
``` cpp
|
| 109 |
valarray();
|
| 110 |
```
|
| 111 |
|
| 112 |
-
*Effects:* Constructs
|
| 113 |
-
zero length.[^10]
|
| 114 |
|
| 115 |
``` cpp
|
| 116 |
-
explicit valarray(size_t);
|
| 117 |
```
|
| 118 |
|
| 119 |
-
|
| 120 |
-
the
|
| 121 |
-
value-initialized ([[dcl.init]]).
|
| 122 |
|
| 123 |
``` cpp
|
| 124 |
-
valarray(const T&, size_t);
|
| 125 |
```
|
| 126 |
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
the first argument.
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
-
valarray(const T*, size_t);
|
| 133 |
```
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
| 140 |
|
| 141 |
``` cpp
|
| 142 |
-
valarray(const valarray
|
| 143 |
```
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
|
| 149 |
``` cpp
|
| 150 |
-
valarray(valarray
|
| 151 |
```
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
*Complexity:* Constant.
|
| 158 |
|
| 159 |
``` cpp
|
| 160 |
valarray(initializer_list<T> il);
|
| 161 |
```
|
| 162 |
|
| 163 |
-
*Effects:*
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
valarray(const slice_array<T>&);
|
| 167 |
valarray(const gslice_array<T>&);
|
| 168 |
valarray(const mask_array<T>&);
|
|
@@ -174,101 +176,103 @@ templates to a `valarray`.
|
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
~valarray();
|
| 177 |
```
|
| 178 |
|
| 179 |
-
The destructor is applied to every element of `*this`; an
|
| 180 |
-
may return all allocated memory.
|
| 181 |
|
| 182 |
#### `valarray` assignment <a id="valarray.assign">[[valarray.assign]]</a>
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
-
valarray
|
| 186 |
```
|
| 187 |
|
| 188 |
-
Each element of the `*this` array is assigned the value of
|
| 189 |
-
corresponding element of
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
|
| 194 |
-
`size() == v.size()`.
|
|
|
|
|
|
|
| 195 |
|
| 196 |
``` cpp
|
| 197 |
-
valarray
|
| 198 |
```
|
| 199 |
|
| 200 |
*Effects:* `*this` obtains the value of `v`. The value of `v` after the
|
| 201 |
assignment is not specified.
|
| 202 |
|
|
|
|
|
|
|
| 203 |
*Complexity:* Linear.
|
| 204 |
|
| 205 |
``` cpp
|
| 206 |
valarray& operator=(initializer_list<T> il);
|
| 207 |
```
|
| 208 |
|
| 209 |
-
*Effects:* `*this = valarray(il)`
|
| 210 |
-
|
| 211 |
-
*Returns:* `*this`.
|
| 212 |
|
| 213 |
``` cpp
|
| 214 |
-
valarray
|
| 215 |
```
|
| 216 |
|
| 217 |
-
|
| 218 |
-
|
|
|
|
| 219 |
|
| 220 |
``` cpp
|
| 221 |
-
valarray
|
| 222 |
-
valarray
|
| 223 |
-
valarray
|
| 224 |
-
valarray
|
| 225 |
```
|
| 226 |
|
| 227 |
*Requires:* The length of the array to which the argument refers equals
|
| 228 |
-
`size()`.
|
|
|
|
|
|
|
| 229 |
|
| 230 |
These operators allow the results of a generalized subscripting
|
| 231 |
operation to be assigned directly to a `valarray`.
|
| 232 |
|
| 233 |
-
If the value of an element in the left-hand side of a valarray
|
| 234 |
-
assignment operator depends on the value of another element in that
|
| 235 |
-
left-hand side, the resulting behavior is undefined.
|
| 236 |
-
|
| 237 |
#### `valarray` element access <a id="valarray.access">[[valarray.access]]</a>
|
| 238 |
|
| 239 |
``` cpp
|
| 240 |
-
const T& operator[](size_t) const;
|
| 241 |
-
T& operator[](size_t);
|
| 242 |
```
|
| 243 |
|
| 244 |
-
|
| 245 |
-
of the array.
|
| 246 |
|
| 247 |
-
|
| 248 |
-
non-constant `valarray<T> a`, any `T q`, and for any `size_t i` such
|
| 249 |
-
that the value of `i` is less than the length of `a`.
|
| 250 |
|
| 251 |
-
The expression `
|
| 252 |
-
|
| 253 |
-
|
|
|
|
| 254 |
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
The reference returned by the subscript operator for an array shall be
|
| 262 |
valid until the member function
|
| 263 |
`resize(size_t, T)` ([[valarray.members]]) is called for that array or
|
| 264 |
until the lifetime of that array ends, whichever happens first.
|
| 265 |
|
| 266 |
-
If the subscript operator is invoked with a `size_t` argument whose
|
| 267 |
-
value is not less than the length of the array, the behavior is
|
| 268 |
-
undefined.
|
| 269 |
-
|
| 270 |
#### `valarray` subset operations <a id="valarray.sub">[[valarray.sub]]</a>
|
| 271 |
|
| 272 |
The member `operator[]` is overloaded to provide several ways to select
|
| 273 |
sequences of elements from among those controlled by `*this`. Each of
|
| 274 |
these operations returns a subset of the array. The const-qualified
|
|
@@ -278,200 +282,231 @@ the original array, working in conjunction with various overloads of
|
|
| 278 |
`operator=` and other assigning operators to allow selective replacement
|
| 279 |
(slicing) of the controlled sequence. In each case the selected
|
| 280 |
element(s) must exist.
|
| 281 |
|
| 282 |
``` cpp
|
| 283 |
-
valarray
|
| 284 |
```
|
| 285 |
|
| 286 |
-
*Returns:*
|
| 287 |
-
|
|
|
|
|
|
|
| 288 |
|
| 289 |
``` cpp
|
| 290 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 291 |
// v0[slice(2, 5, 3)] returns valarray<char>("cfilo", 5)
|
| 292 |
```
|
| 293 |
|
|
|
|
|
|
|
| 294 |
``` cpp
|
| 295 |
slice_array<T> operator[](slice slicearr);
|
| 296 |
```
|
| 297 |
|
| 298 |
*Returns:* An object that holds references to elements of the controlled
|
| 299 |
sequence selected by `slicearr`.
|
| 300 |
|
|
|
|
|
|
|
| 301 |
``` cpp
|
| 302 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 303 |
valarray<char> v1("ABCDE", 5);
|
| 304 |
v0[slice(2, 5, 3)] = v1;
|
| 305 |
// v0 == valarray<char>("abAdeBghCjkDmnEp", 16);
|
| 306 |
```
|
| 307 |
|
|
|
|
|
|
|
| 308 |
``` cpp
|
| 309 |
-
valarray
|
| 310 |
```
|
| 311 |
|
| 312 |
-
*Returns:*
|
| 313 |
-
|
|
|
|
|
|
|
| 314 |
|
| 315 |
``` cpp
|
| 316 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 317 |
const size_t lv[] = { 2, 3 };
|
| 318 |
const size_t dv[] = { 7, 2 };
|
| 319 |
const valarray<size_t> len(lv, 2), str(dv, 2);
|
| 320 |
// v0[gslice(3, len, str)] returns
|
| 321 |
// valarray<char>("dfhkmo", 6)
|
| 322 |
```
|
| 323 |
|
|
|
|
|
|
|
| 324 |
``` cpp
|
| 325 |
gslice_array<T> operator[](const gslice& gslicearr);
|
| 326 |
```
|
| 327 |
|
| 328 |
*Returns:* An object that holds references to elements of the controlled
|
| 329 |
sequence selected by `gslicearr`.
|
| 330 |
|
|
|
|
|
|
|
| 331 |
``` cpp
|
| 332 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 333 |
-
valarray<char> v1("
|
| 334 |
const size_t lv[] = { 2, 3 };
|
| 335 |
const size_t dv[] = { 7, 2 };
|
| 336 |
const valarray<size_t> len(lv, 2), str(dv, 2);
|
| 337 |
v0[gslice(3, len, str)] = v1;
|
| 338 |
// v0 == valarray<char>("abcAeBgCijDlEnFp", 16)
|
| 339 |
```
|
| 340 |
|
|
|
|
|
|
|
| 341 |
``` cpp
|
| 342 |
-
valarray
|
| 343 |
```
|
| 344 |
|
| 345 |
-
*Returns:*
|
| 346 |
-
|
|
|
|
|
|
|
| 347 |
|
| 348 |
``` cpp
|
| 349 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 350 |
const bool vb[] = { false, false, true, true, false, true };
|
| 351 |
// v0[valarray<bool>(vb, 6)] returns
|
| 352 |
// valarray<char>("cdf", 3)
|
| 353 |
```
|
| 354 |
|
|
|
|
|
|
|
| 355 |
``` cpp
|
| 356 |
mask_array<T> operator[](const valarray<bool>& boolarr);
|
| 357 |
```
|
| 358 |
|
| 359 |
*Returns:* An object that holds references to elements of the controlled
|
| 360 |
sequence selected by `boolarr`.
|
| 361 |
|
|
|
|
|
|
|
| 362 |
``` cpp
|
| 363 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 364 |
valarray<char> v1("ABC", 3);
|
| 365 |
const bool vb[] = { false, false, true, true, false, true };
|
| 366 |
v0[valarray<bool>(vb, 6)] = v1;
|
| 367 |
// v0 == valarray<char>("abABeCghijklmnop", 16)
|
| 368 |
```
|
| 369 |
|
|
|
|
|
|
|
| 370 |
``` cpp
|
| 371 |
-
valarray
|
| 372 |
```
|
| 373 |
|
| 374 |
-
*Returns:*
|
| 375 |
-
|
|
|
|
|
|
|
| 376 |
|
| 377 |
``` cpp
|
| 378 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 379 |
const size_t vi[] = { 7, 5, 2, 3, 8 };
|
| 380 |
// v0[valarray<size_t>(vi, 5)] returns
|
| 381 |
// valarray<char>("hfcdi", 5)
|
| 382 |
```
|
| 383 |
|
|
|
|
|
|
|
| 384 |
``` cpp
|
| 385 |
indirect_array<T> operator[](const valarray<size_t>& indarr);
|
| 386 |
```
|
| 387 |
|
| 388 |
*Returns:* An object that holds references to elements of the controlled
|
| 389 |
sequence selected by `indarr`.
|
| 390 |
|
|
|
|
|
|
|
| 391 |
``` cpp
|
| 392 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 393 |
valarray<char> v1("ABCDE", 5);
|
| 394 |
const size_t vi[] = { 7, 5, 2, 3, 8 };
|
| 395 |
v0[valarray<size_t>(vi, 5)] = v1;
|
| 396 |
// v0 == valarray<char>("abCDeBgAEjklmnop", 16)
|
| 397 |
```
|
| 398 |
|
|
|
|
|
|
|
| 399 |
#### `valarray` unary operators <a id="valarray.unary">[[valarray.unary]]</a>
|
| 400 |
|
| 401 |
``` cpp
|
| 402 |
-
valarray
|
| 403 |
-
valarray
|
| 404 |
-
valarray
|
| 405 |
valarray<bool> operator!() const;
|
| 406 |
```
|
| 407 |
|
| 408 |
-
Each of these operators may only be instantiated for a type
|
| 409 |
-
the indicated operator can be applied and for which the
|
| 410 |
-
operator returns a value which is of type `T` (`bool` for
|
| 411 |
-
or which may be unambiguously implicitly converted to type
|
| 412 |
-
for `operator!`).
|
| 413 |
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
element of the array.
|
| 418 |
|
| 419 |
-
#### `valarray`
|
| 420 |
|
| 421 |
``` cpp
|
| 422 |
-
valarray
|
| 423 |
-
valarray
|
| 424 |
-
valarray
|
| 425 |
-
valarray
|
| 426 |
-
valarray
|
| 427 |
-
valarray
|
| 428 |
-
valarray
|
| 429 |
-
valarray
|
| 430 |
-
valarray
|
| 431 |
-
valarray
|
| 432 |
```
|
| 433 |
|
| 434 |
-
Each of these operators may only be
|
| 435 |
-
the indicated operator can be applied
|
| 436 |
-
|
| 437 |
-
|
|
|
|
| 438 |
|
| 439 |
-
|
|
|
|
| 440 |
|
| 441 |
-
|
| 442 |
-
behavior is undefined. The appearance of an array on the left-hand side
|
| 443 |
-
of a computed assignment does `not` invalidate references or pointers.
|
| 444 |
|
| 445 |
-
|
| 446 |
-
assignment
|
| 447 |
-
hand side, the resulting behavior is undefined.
|
| 448 |
|
| 449 |
``` cpp
|
| 450 |
-
valarray
|
| 451 |
-
valarray
|
| 452 |
-
valarray
|
| 453 |
-
valarray
|
| 454 |
-
valarray
|
| 455 |
-
valarray
|
| 456 |
-
valarray
|
| 457 |
-
valarray
|
| 458 |
-
valarray
|
| 459 |
-
valarray
|
| 460 |
```
|
| 461 |
|
| 462 |
-
Each of these operators may only be instantiated for a type
|
| 463 |
-
the indicated operator can be applied
|
|
|
|
| 464 |
|
| 465 |
-
Each of these operators applies the indicated operation to
|
| 466 |
-
|
| 467 |
|
| 468 |
-
|
| 469 |
|
| 470 |
-
The appearance of an array on the left-hand side of a
|
| 471 |
-
assignment does
|
| 472 |
-
of the array.
|
| 473 |
|
| 474 |
#### `valarray` member functions <a id="valarray.members">[[valarray.members]]</a>
|
| 475 |
|
| 476 |
``` cpp
|
| 477 |
void swap(valarray& v) noexcept;
|
|
@@ -492,50 +527,76 @@ size_t size() const;
|
|
| 492 |
|
| 493 |
``` cpp
|
| 494 |
T sum() const;
|
| 495 |
```
|
| 496 |
|
| 497 |
-
This function may only be instantiated for a
|
| 498 |
-
`operator+=` can be applied.
|
| 499 |
-
elements of the array.
|
| 500 |
|
| 501 |
-
|
| 502 |
-
length 1,
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
unspecified order.
|
| 506 |
|
| 507 |
``` cpp
|
| 508 |
T min() const;
|
| 509 |
```
|
| 510 |
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
|
|
|
| 515 |
|
| 516 |
``` cpp
|
| 517 |
T max() const;
|
| 518 |
```
|
| 519 |
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
|
|
|
| 524 |
|
| 525 |
``` cpp
|
| 526 |
-
valarray
|
| 527 |
```
|
| 528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
``` cpp
|
| 530 |
-
valarray
|
| 531 |
```
|
| 532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
``` cpp
|
| 534 |
-
valarray
|
| 535 |
-
valarray
|
| 536 |
```
|
| 537 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
``` cpp
|
| 539 |
void resize(size_t sz, T c = T());
|
| 540 |
```
|
| 541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
namespace std {
|
| 7 |
template<class T> class valarray {
|
| 8 |
public:
|
| 9 |
+
using value_type = T;
|
| 10 |
|
| 11 |
+
// [valarray.cons], construct/destroy
|
| 12 |
valarray();
|
| 13 |
explicit valarray(size_t);
|
| 14 |
valarray(const T&, size_t);
|
| 15 |
valarray(const T*, size_t);
|
| 16 |
valarray(const valarray&);
|
|
|
|
| 20 |
valarray(const mask_array<T>&);
|
| 21 |
valarray(const indirect_array<T>&);
|
| 22 |
valarray(initializer_list<T>);
|
| 23 |
~valarray();
|
| 24 |
|
| 25 |
+
// [valarray.assign], assignment
|
| 26 |
+
valarray& operator=(const valarray&);
|
| 27 |
+
valarray& operator=(valarray&&) noexcept;
|
| 28 |
valarray& operator=(initializer_list<T>);
|
| 29 |
+
valarray& operator=(const T&);
|
| 30 |
+
valarray& operator=(const slice_array<T>&);
|
| 31 |
+
valarray& operator=(const gslice_array<T>&);
|
| 32 |
+
valarray& operator=(const mask_array<T>&);
|
| 33 |
+
valarray& operator=(const indirect_array<T>&);
|
| 34 |
|
| 35 |
+
// [valarray.access], element access
|
| 36 |
const T& operator[](size_t) const;
|
| 37 |
T& operator[](size_t);
|
| 38 |
|
| 39 |
+
// [valarray.sub], subset operations
|
| 40 |
+
valarray operator[](slice) const;
|
| 41 |
slice_array<T> operator[](slice);
|
| 42 |
+
valarray operator[](const gslice&) const;
|
| 43 |
gslice_array<T> operator[](const gslice&);
|
| 44 |
+
valarray operator[](const valarray<bool>&) const;
|
| 45 |
mask_array<T> operator[](const valarray<bool>&);
|
| 46 |
+
valarray operator[](const valarray<size_t>&) const;
|
| 47 |
indirect_array<T> operator[](const valarray<size_t>&);
|
| 48 |
|
| 49 |
+
// [valarray.unary], unary operators
|
| 50 |
+
valarray operator+() const;
|
| 51 |
+
valarray operator-() const;
|
| 52 |
+
valarray operator~() const;
|
| 53 |
valarray<bool> operator!() const;
|
| 54 |
|
| 55 |
+
// [valarray.cassign], compound assignment
|
| 56 |
+
valarray& operator*= (const T&);
|
| 57 |
+
valarray& operator/= (const T&);
|
| 58 |
+
valarray& operator%= (const T&);
|
| 59 |
+
valarray& operator+= (const T&);
|
| 60 |
+
valarray& operator-= (const T&);
|
| 61 |
+
valarray& operator^= (const T&);
|
| 62 |
+
valarray& operator&= (const T&);
|
| 63 |
+
valarray& operator|= (const T&);
|
| 64 |
+
valarray& operator<<=(const T&);
|
| 65 |
+
valarray& operator>>=(const T&);
|
| 66 |
|
| 67 |
+
valarray& operator*= (const valarray&);
|
| 68 |
+
valarray& operator/= (const valarray&);
|
| 69 |
+
valarray& operator%= (const valarray&);
|
| 70 |
+
valarray& operator+= (const valarray&);
|
| 71 |
+
valarray& operator-= (const valarray&);
|
| 72 |
+
valarray& operator^= (const valarray&);
|
| 73 |
+
valarray& operator|= (const valarray&);
|
| 74 |
+
valarray& operator&= (const valarray&);
|
| 75 |
+
valarray& operator<<=(const valarray&);
|
| 76 |
+
valarray& operator>>=(const valarray&);
|
| 77 |
|
| 78 |
+
// [valarray.members], member functions
|
| 79 |
void swap(valarray&) noexcept;
|
| 80 |
|
| 81 |
size_t size() const;
|
| 82 |
|
| 83 |
T sum() const;
|
| 84 |
T min() const;
|
| 85 |
T max() const;
|
| 86 |
|
| 87 |
+
valarray shift (int) const;
|
| 88 |
+
valarray cshift(int) const;
|
| 89 |
+
valarray apply(T func(T)) const;
|
| 90 |
+
valarray apply(T func(const T&)) const;
|
| 91 |
void resize(size_t sz, T c = T());
|
| 92 |
};
|
| 93 |
+
|
| 94 |
+
template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>;
|
| 95 |
}
|
| 96 |
```
|
| 97 |
|
| 98 |
The class template `valarray<T>` is a one-dimensional smart array, with
|
| 99 |
elements numbered sequentially from zero. It is a representation of the
|
| 100 |
+
mathematical concept of an ordered set of values. For convenience, an
|
| 101 |
+
object of type `valarray<T>` is referred to as an “array” throughout the
|
| 102 |
+
remainder of [[numarray]]. The illusion of higher dimensionality may be
|
| 103 |
+
produced by the familiar idiom of computed indices, together with the
|
| 104 |
+
powerful subsetting capabilities provided by the generalized subscript
|
| 105 |
+
operators.[^8]
|
| 106 |
|
| 107 |
An implementation is permitted to qualify any of the functions declared
|
| 108 |
in `<valarray>` as `inline`.
|
| 109 |
|
| 110 |
#### `valarray` constructors <a id="valarray.cons">[[valarray.cons]]</a>
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
valarray();
|
| 114 |
```
|
| 115 |
|
| 116 |
+
*Effects:* Constructs a `valarray` that has zero length.[^9]
|
|
|
|
| 117 |
|
| 118 |
``` cpp
|
| 119 |
+
explicit valarray(size_t n);
|
| 120 |
```
|
| 121 |
|
| 122 |
+
*Effects:* Constructs a `valarray` that has length `n`. Each element of
|
| 123 |
+
the array is value-initialized ([[dcl.init]]).
|
|
|
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
+
valarray(const T& v, size_t n);
|
| 127 |
```
|
| 128 |
|
| 129 |
+
*Effects:* Constructs a `valarray` that has length `n`. Each element of
|
| 130 |
+
the array is initialized with `v`.
|
|
|
|
| 131 |
|
| 132 |
``` cpp
|
| 133 |
+
valarray(const T* p, size_t n);
|
| 134 |
```
|
| 135 |
|
| 136 |
+
*Requires:* `p` points to an array ([[dcl.array]]) of at least `n`
|
| 137 |
+
elements.
|
| 138 |
+
|
| 139 |
+
*Effects:* Constructs a `valarray` that has length `n`. The values of
|
| 140 |
+
the elements of the array are initialized with the first `n` values
|
| 141 |
+
pointed to by the first argument.[^10]
|
| 142 |
|
| 143 |
``` cpp
|
| 144 |
+
valarray(const valarray& v);
|
| 145 |
```
|
| 146 |
|
| 147 |
+
*Effects:* Constructs a `valarray` that has the same length as `v`. The
|
| 148 |
+
elements are initialized with the values of the corresponding elements
|
| 149 |
+
of `v`.[^11]
|
| 150 |
|
| 151 |
``` cpp
|
| 152 |
+
valarray(valarray&& v) noexcept;
|
| 153 |
```
|
| 154 |
|
| 155 |
+
*Effects:* Constructs a `valarray` that has the same length as `v`. The
|
| 156 |
+
elements are initialized with the values of the corresponding elements
|
| 157 |
+
of `v`.
|
| 158 |
|
| 159 |
*Complexity:* Constant.
|
| 160 |
|
| 161 |
``` cpp
|
| 162 |
valarray(initializer_list<T> il);
|
| 163 |
```
|
| 164 |
|
| 165 |
+
*Effects:* Equivalent to `valarray(il.begin(), il.size())`.
|
| 166 |
|
| 167 |
``` cpp
|
| 168 |
valarray(const slice_array<T>&);
|
| 169 |
valarray(const gslice_array<T>&);
|
| 170 |
valarray(const mask_array<T>&);
|
|
|
|
| 176 |
|
| 177 |
``` cpp
|
| 178 |
~valarray();
|
| 179 |
```
|
| 180 |
|
| 181 |
+
*Effects:* The destructor is applied to every element of `*this`; an
|
| 182 |
+
implementation may return all allocated memory.
|
| 183 |
|
| 184 |
#### `valarray` assignment <a id="valarray.assign">[[valarray.assign]]</a>
|
| 185 |
|
| 186 |
``` cpp
|
| 187 |
+
valarray& operator=(const valarray& v);
|
| 188 |
```
|
| 189 |
|
| 190 |
+
*Effects:* Each element of the `*this` array is assigned the value of
|
| 191 |
+
the corresponding element of `v`. If the length of `v` is not equal to
|
| 192 |
+
the length of `*this`, resizes `*this` to make the two arrays the same
|
| 193 |
+
length, as if by calling `resize(v.size())`, before performing the
|
| 194 |
+
assignment.
|
| 195 |
|
| 196 |
+
*Postconditions:* `size() == v.size()`.
|
| 197 |
+
|
| 198 |
+
*Returns:* `*this`.
|
| 199 |
|
| 200 |
``` cpp
|
| 201 |
+
valarray& operator=(valarray&& v) noexcept;
|
| 202 |
```
|
| 203 |
|
| 204 |
*Effects:* `*this` obtains the value of `v`. The value of `v` after the
|
| 205 |
assignment is not specified.
|
| 206 |
|
| 207 |
+
*Returns:* `*this`.
|
| 208 |
+
|
| 209 |
*Complexity:* Linear.
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
valarray& operator=(initializer_list<T> il);
|
| 213 |
```
|
| 214 |
|
| 215 |
+
*Effects:* Equivalent to: `return *this = valarray(il);`
|
|
|
|
|
|
|
| 216 |
|
| 217 |
``` cpp
|
| 218 |
+
valarray& operator=(const T& v);
|
| 219 |
```
|
| 220 |
|
| 221 |
+
*Effects:* Assigns `v` to each element of `*this`.
|
| 222 |
+
|
| 223 |
+
*Returns:* `*this`.
|
| 224 |
|
| 225 |
``` cpp
|
| 226 |
+
valarray& operator=(const slice_array<T>&);
|
| 227 |
+
valarray& operator=(const gslice_array<T>&);
|
| 228 |
+
valarray& operator=(const mask_array<T>&);
|
| 229 |
+
valarray& operator=(const indirect_array<T>&);
|
| 230 |
```
|
| 231 |
|
| 232 |
*Requires:* The length of the array to which the argument refers equals
|
| 233 |
+
`size()`. The value of an element in the left-hand side of a `valarray`
|
| 234 |
+
assignment operator does not depend on the value of another element in
|
| 235 |
+
that left-hand side.
|
| 236 |
|
| 237 |
These operators allow the results of a generalized subscripting
|
| 238 |
operation to be assigned directly to a `valarray`.
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
#### `valarray` element access <a id="valarray.access">[[valarray.access]]</a>
|
| 241 |
|
| 242 |
``` cpp
|
| 243 |
+
const T& operator[](size_t n) const;
|
| 244 |
+
T& operator[](size_t n);
|
| 245 |
```
|
| 246 |
|
| 247 |
+
*Requires:* `n < size()`.
|
|
|
|
| 248 |
|
| 249 |
+
*Returns:* A reference to the corresponding element of the array.
|
|
|
|
|
|
|
| 250 |
|
| 251 |
+
[*Note 1*: The expression `(a[i] = q, a[i]) == q` evaluates to `true`
|
| 252 |
+
for any non-constant `valarray<T> a`, any `T q`, and for any `size_t i`
|
| 253 |
+
such that the value of `i` is less than the length of
|
| 254 |
+
`a`. — *end note*]
|
| 255 |
|
| 256 |
+
*Remarks:* The expression `&a[i+j] == &a[i] + j` evaluates to `true` for
|
| 257 |
+
all `size_t i` and `size_t j` such that `i+j < a.size()`.
|
| 258 |
+
|
| 259 |
+
The expression `&a[i] != &b[j]` evaluates to `true` for any two arrays
|
| 260 |
+
`a` and `b` and for any `size_t i` and `size_t j` such that
|
| 261 |
+
`i < a.size()` and `j < b.size()`.
|
| 262 |
+
|
| 263 |
+
[*Note 2*: This property indicates an absence of aliasing and may be
|
| 264 |
+
used to advantage by optimizing compilers. Compilers may take advantage
|
| 265 |
+
of inlining, constant propagation, loop fusion, tracking of pointers
|
| 266 |
+
obtained from `operator new`, and other techniques to generate efficient
|
| 267 |
+
`valarray`s. — *end note*]
|
| 268 |
|
| 269 |
The reference returned by the subscript operator for an array shall be
|
| 270 |
valid until the member function
|
| 271 |
`resize(size_t, T)` ([[valarray.members]]) is called for that array or
|
| 272 |
until the lifetime of that array ends, whichever happens first.
|
| 273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
#### `valarray` subset operations <a id="valarray.sub">[[valarray.sub]]</a>
|
| 275 |
|
| 276 |
The member `operator[]` is overloaded to provide several ways to select
|
| 277 |
sequences of elements from among those controlled by `*this`. Each of
|
| 278 |
these operations returns a subset of the array. The const-qualified
|
|
|
|
| 282 |
`operator=` and other assigning operators to allow selective replacement
|
| 283 |
(slicing) of the controlled sequence. In each case the selected
|
| 284 |
element(s) must exist.
|
| 285 |
|
| 286 |
``` cpp
|
| 287 |
+
valarray operator[](slice slicearr) const;
|
| 288 |
```
|
| 289 |
|
| 290 |
+
*Returns:* A `valarray` containing those elements of the controlled
|
| 291 |
+
sequence designated by `slicearr`.
|
| 292 |
+
|
| 293 |
+
[*Example 1*:
|
| 294 |
|
| 295 |
``` cpp
|
| 296 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 297 |
// v0[slice(2, 5, 3)] returns valarray<char>("cfilo", 5)
|
| 298 |
```
|
| 299 |
|
| 300 |
+
— *end example*]
|
| 301 |
+
|
| 302 |
``` cpp
|
| 303 |
slice_array<T> operator[](slice slicearr);
|
| 304 |
```
|
| 305 |
|
| 306 |
*Returns:* An object that holds references to elements of the controlled
|
| 307 |
sequence selected by `slicearr`.
|
| 308 |
|
| 309 |
+
[*Example 2*:
|
| 310 |
+
|
| 311 |
``` cpp
|
| 312 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 313 |
valarray<char> v1("ABCDE", 5);
|
| 314 |
v0[slice(2, 5, 3)] = v1;
|
| 315 |
// v0 == valarray<char>("abAdeBghCjkDmnEp", 16);
|
| 316 |
```
|
| 317 |
|
| 318 |
+
— *end example*]
|
| 319 |
+
|
| 320 |
``` cpp
|
| 321 |
+
valarray operator[](const gslice& gslicearr) const;
|
| 322 |
```
|
| 323 |
|
| 324 |
+
*Returns:* A `valarray` containing those elements of the controlled
|
| 325 |
+
sequence designated by `gslicearr`.
|
| 326 |
+
|
| 327 |
+
[*Example 3*:
|
| 328 |
|
| 329 |
``` cpp
|
| 330 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 331 |
const size_t lv[] = { 2, 3 };
|
| 332 |
const size_t dv[] = { 7, 2 };
|
| 333 |
const valarray<size_t> len(lv, 2), str(dv, 2);
|
| 334 |
// v0[gslice(3, len, str)] returns
|
| 335 |
// valarray<char>("dfhkmo", 6)
|
| 336 |
```
|
| 337 |
|
| 338 |
+
— *end example*]
|
| 339 |
+
|
| 340 |
``` cpp
|
| 341 |
gslice_array<T> operator[](const gslice& gslicearr);
|
| 342 |
```
|
| 343 |
|
| 344 |
*Returns:* An object that holds references to elements of the controlled
|
| 345 |
sequence selected by `gslicearr`.
|
| 346 |
|
| 347 |
+
[*Example 4*:
|
| 348 |
+
|
| 349 |
``` cpp
|
| 350 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 351 |
+
valarray<char> v1("ABCDEF", 6);
|
| 352 |
const size_t lv[] = { 2, 3 };
|
| 353 |
const size_t dv[] = { 7, 2 };
|
| 354 |
const valarray<size_t> len(lv, 2), str(dv, 2);
|
| 355 |
v0[gslice(3, len, str)] = v1;
|
| 356 |
// v0 == valarray<char>("abcAeBgCijDlEnFp", 16)
|
| 357 |
```
|
| 358 |
|
| 359 |
+
— *end example*]
|
| 360 |
+
|
| 361 |
``` cpp
|
| 362 |
+
valarray operator[](const valarray<bool>& boolarr) const;
|
| 363 |
```
|
| 364 |
|
| 365 |
+
*Returns:* A `valarray` containing those elements of the controlled
|
| 366 |
+
sequence designated by `boolarr`.
|
| 367 |
+
|
| 368 |
+
[*Example 5*:
|
| 369 |
|
| 370 |
``` cpp
|
| 371 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 372 |
const bool vb[] = { false, false, true, true, false, true };
|
| 373 |
// v0[valarray<bool>(vb, 6)] returns
|
| 374 |
// valarray<char>("cdf", 3)
|
| 375 |
```
|
| 376 |
|
| 377 |
+
— *end example*]
|
| 378 |
+
|
| 379 |
``` cpp
|
| 380 |
mask_array<T> operator[](const valarray<bool>& boolarr);
|
| 381 |
```
|
| 382 |
|
| 383 |
*Returns:* An object that holds references to elements of the controlled
|
| 384 |
sequence selected by `boolarr`.
|
| 385 |
|
| 386 |
+
[*Example 6*:
|
| 387 |
+
|
| 388 |
``` cpp
|
| 389 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 390 |
valarray<char> v1("ABC", 3);
|
| 391 |
const bool vb[] = { false, false, true, true, false, true };
|
| 392 |
v0[valarray<bool>(vb, 6)] = v1;
|
| 393 |
// v0 == valarray<char>("abABeCghijklmnop", 16)
|
| 394 |
```
|
| 395 |
|
| 396 |
+
— *end example*]
|
| 397 |
+
|
| 398 |
``` cpp
|
| 399 |
+
valarray operator[](const valarray<size_t>& indarr) const;
|
| 400 |
```
|
| 401 |
|
| 402 |
+
*Returns:* A `valarray` containing those elements of the controlled
|
| 403 |
+
sequence designated by `indarr`.
|
| 404 |
+
|
| 405 |
+
[*Example 7*:
|
| 406 |
|
| 407 |
``` cpp
|
| 408 |
const valarray<char> v0("abcdefghijklmnop", 16);
|
| 409 |
const size_t vi[] = { 7, 5, 2, 3, 8 };
|
| 410 |
// v0[valarray<size_t>(vi, 5)] returns
|
| 411 |
// valarray<char>("hfcdi", 5)
|
| 412 |
```
|
| 413 |
|
| 414 |
+
— *end example*]
|
| 415 |
+
|
| 416 |
``` cpp
|
| 417 |
indirect_array<T> operator[](const valarray<size_t>& indarr);
|
| 418 |
```
|
| 419 |
|
| 420 |
*Returns:* An object that holds references to elements of the controlled
|
| 421 |
sequence selected by `indarr`.
|
| 422 |
|
| 423 |
+
[*Example 8*:
|
| 424 |
+
|
| 425 |
``` cpp
|
| 426 |
valarray<char> v0("abcdefghijklmnop", 16);
|
| 427 |
valarray<char> v1("ABCDE", 5);
|
| 428 |
const size_t vi[] = { 7, 5, 2, 3, 8 };
|
| 429 |
v0[valarray<size_t>(vi, 5)] = v1;
|
| 430 |
// v0 == valarray<char>("abCDeBgAEjklmnop", 16)
|
| 431 |
```
|
| 432 |
|
| 433 |
+
— *end example*]
|
| 434 |
+
|
| 435 |
#### `valarray` unary operators <a id="valarray.unary">[[valarray.unary]]</a>
|
| 436 |
|
| 437 |
``` cpp
|
| 438 |
+
valarray operator+() const;
|
| 439 |
+
valarray operator-() const;
|
| 440 |
+
valarray operator~() const;
|
| 441 |
valarray<bool> operator!() const;
|
| 442 |
```
|
| 443 |
|
| 444 |
+
*Requires:* Each of these operators may only be instantiated for a type
|
| 445 |
+
`T` to which the indicated operator can be applied and for which the
|
| 446 |
+
indicated operator returns a value which is of type `T` (`bool` for
|
| 447 |
+
`operator!`) or which may be unambiguously implicitly converted to type
|
| 448 |
+
`T` (`bool` for `operator!`).
|
| 449 |
|
| 450 |
+
*Returns:* A `valarray` whose length is `size()`. Each element of the
|
| 451 |
+
returned array is initialized with the result of applying the indicated
|
| 452 |
+
operator to the corresponding element of the array.
|
|
|
|
| 453 |
|
| 454 |
+
#### `valarray` compound assignment <a id="valarray.cassign">[[valarray.cassign]]</a>
|
| 455 |
|
| 456 |
``` cpp
|
| 457 |
+
valarray& operator*= (const valarray& v);
|
| 458 |
+
valarray& operator/= (const valarray& v);
|
| 459 |
+
valarray& operator%= (const valarray& v);
|
| 460 |
+
valarray& operator+= (const valarray& v);
|
| 461 |
+
valarray& operator-= (const valarray& v);
|
| 462 |
+
valarray& operator^= (const valarray& v);
|
| 463 |
+
valarray& operator&= (const valarray& v);
|
| 464 |
+
valarray& operator|= (const valarray& v);
|
| 465 |
+
valarray& operator<<=(const valarray& v);
|
| 466 |
+
valarray& operator>>=(const valarray& v);
|
| 467 |
```
|
| 468 |
|
| 469 |
+
*Requires:* `size() == v.size()`. Each of these operators may only be
|
| 470 |
+
instantiated for a type `T` if the indicated operator can be applied to
|
| 471 |
+
two operands of type `T`. The value of an element in the left-hand side
|
| 472 |
+
of a valarray compound assignment operator does not depend on the value
|
| 473 |
+
of another element in that left hand side.
|
| 474 |
|
| 475 |
+
*Effects:* Each of these operators performs the indicated operation on
|
| 476 |
+
each of the elements of `*this` and the corresponding element of `v`.
|
| 477 |
|
| 478 |
+
*Returns:* `*this`.
|
|
|
|
|
|
|
| 479 |
|
| 480 |
+
*Remarks:* The appearance of an array on the left-hand side of a
|
| 481 |
+
compound assignment does not invalidate references or pointers.
|
|
|
|
| 482 |
|
| 483 |
``` cpp
|
| 484 |
+
valarray& operator*= (const T& v);
|
| 485 |
+
valarray& operator/= (const T& v);
|
| 486 |
+
valarray& operator%= (const T& v);
|
| 487 |
+
valarray& operator+= (const T& v);
|
| 488 |
+
valarray& operator-= (const T& v);
|
| 489 |
+
valarray& operator^= (const T& v);
|
| 490 |
+
valarray& operator&= (const T& v);
|
| 491 |
+
valarray& operator|= (const T& v);
|
| 492 |
+
valarray& operator<<=(const T& v);
|
| 493 |
+
valarray& operator>>=(const T& v);
|
| 494 |
```
|
| 495 |
|
| 496 |
+
*Requires:* Each of these operators may only be instantiated for a type
|
| 497 |
+
`T` if the indicated operator can be applied to two operands of type
|
| 498 |
+
`T`.
|
| 499 |
|
| 500 |
+
*Effects:* Each of these operators applies the indicated operation to
|
| 501 |
+
each element of `*this` and `v`.
|
| 502 |
|
| 503 |
+
*Returns:* `*this`
|
| 504 |
|
| 505 |
+
*Remarks:* The appearance of an array on the left-hand side of a
|
| 506 |
+
compound assignment does not invalidate references or pointers to the
|
| 507 |
+
elements of the array.
|
| 508 |
|
| 509 |
#### `valarray` member functions <a id="valarray.members">[[valarray.members]]</a>
|
| 510 |
|
| 511 |
``` cpp
|
| 512 |
void swap(valarray& v) noexcept;
|
|
|
|
| 527 |
|
| 528 |
``` cpp
|
| 529 |
T sum() const;
|
| 530 |
```
|
| 531 |
|
| 532 |
+
*Requires:* `size() > 0`. This function may only be instantiated for a
|
| 533 |
+
type `T` to which `operator+=` can be applied.
|
|
|
|
| 534 |
|
| 535 |
+
*Returns:* The sum of all the elements of the array. If the array has
|
| 536 |
+
length 1, returns the value of element 0. Otherwise, the returned value
|
| 537 |
+
is calculated by applying `operator+=` to a copy of an element of the
|
| 538 |
+
array and all other elements of the array in an unspecified order.
|
|
|
|
| 539 |
|
| 540 |
``` cpp
|
| 541 |
T min() const;
|
| 542 |
```
|
| 543 |
|
| 544 |
+
*Requires:* `size() > 0`
|
| 545 |
+
|
| 546 |
+
*Returns:* The minimum value contained in `*this`. For an array of
|
| 547 |
+
length 1, the value of element 0 is returned. For all other array
|
| 548 |
+
lengths, the determination is made using `operator<`.
|
| 549 |
|
| 550 |
``` cpp
|
| 551 |
T max() const;
|
| 552 |
```
|
| 553 |
|
| 554 |
+
*Requires:* `size() > 0`.
|
| 555 |
+
|
| 556 |
+
*Returns:* The maximum value contained in `*this`. For an array of
|
| 557 |
+
length 1, the value of element 0 is returned. For all other array
|
| 558 |
+
lengths, the determination is made using `operator<`.
|
| 559 |
|
| 560 |
``` cpp
|
| 561 |
+
valarray shift(int n) const;
|
| 562 |
```
|
| 563 |
|
| 564 |
+
*Returns:* A `valarray` of length `size()`, each of whose elements *I*
|
| 565 |
+
is `(*this)[`*`I`*` + n]` if *`I`*` + n` is non-negative and less than
|
| 566 |
+
`size()`, otherwise `T()`.
|
| 567 |
+
|
| 568 |
+
[*Note 1*: If element zero is taken as the leftmost element, a positive
|
| 569 |
+
value of `n` shifts the elements left `n` places, with zero
|
| 570 |
+
fill. — *end note*]
|
| 571 |
+
|
| 572 |
+
[*Example 1*: If the argument has the value -2, the first two elements
|
| 573 |
+
of the result will be value-initialized ([[dcl.init]]); the third
|
| 574 |
+
element of the result will be assigned the value of the first element of
|
| 575 |
+
the argument; etc. — *end example*]
|
| 576 |
+
|
| 577 |
``` cpp
|
| 578 |
+
valarray cshift(int n) const;
|
| 579 |
```
|
| 580 |
|
| 581 |
+
*Returns:* A `valarray` of length `size()` that is a circular shift of
|
| 582 |
+
`*this`. If element zero is taken as the leftmost element, a
|
| 583 |
+
non-negative value of n shifts the elements circularly left n places and
|
| 584 |
+
a negative value of n shifts the elements circularly right -n places.
|
| 585 |
+
|
| 586 |
``` cpp
|
| 587 |
+
valarray apply(T func(T)) const;
|
| 588 |
+
valarray apply(T func(const T&)) const;
|
| 589 |
```
|
| 590 |
|
| 591 |
+
*Returns:* A `valarray` whose length is `size()`. Each element of the
|
| 592 |
+
returned array is assigned the value returned by applying the argument
|
| 593 |
+
function to the corresponding element of `*this`.
|
| 594 |
+
|
| 595 |
``` cpp
|
| 596 |
void resize(size_t sz, T c = T());
|
| 597 |
```
|
| 598 |
|
| 599 |
+
*Effects:* Changes the length of the `*this` array to `sz` and then
|
| 600 |
+
assigns to each element the value of the second argument. Resizing
|
| 601 |
+
invalidates all pointers and references to elements in the array.
|
| 602 |
+
|