public member function
<valarray>
std::valarray::operator= copy (1)valarray& operator=(const valarray& x);fill (2)
valarray& operator=(const T& val);sub-array (3)
valarray& operator=(const slice_array<T>& sub);valarray& operator=(const gslice_array<T>& sub);valarray& operator=(const mask_array<T>& sub);valarray& operator=(const indirect_array<T>& sub);copy/move (1)
valarray& operator=(const valarray& x);valarray& operator=(valarray&& x) noexcept;fill (2)
valarray& operator=(const T& val);sub-array (3)
valarray& operator=(const slice_array<T>& sub);valarray& operator=(const gslice_array<T>& sub);valarray& operator=(const mask_array<T>& sub);valarray& operator=(const indirect_array<T>& sub);
Assign content
Assigns contents to the valarray object:*this
: each element is assigned the value of the corresponding element in x.
*this
after resizing the object (if necessary):
*this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// valarray assignment example
#include <iostream> // std::cout
#include <valarray> // std::valarray, std::slice
int main ()
{ // foo: bar:
std::valarray<int> foo (4); // 0 0 0 0
std::valarray<int> bar (2,4); // 0 0 0 0 2 2 2 2
foo = bar; // 2 2 2 2 2 2 2 2
bar = 5; // 2 2 2 2 5 5 5 5
foo = bar[std::slice (0,4,1)]; // 5 5 5 5 5 5 5 5
std::cout << "foo sums " << foo.sum() << '\n';
return 0;
}
No changes: Valid iterators, references and sub-arrays keep their validity.
For
copy/move assignment (1)when the
sizesdo not match: Invalidates all iterators, references and sub-arrays to elements of the
valarray.
In all other cases: Valid iterators, references and sub-arrays keep their validity.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4