Standard C++ Library Reference ISO/IEC (VERSION3)
valarray::operator=
valarray<Ty>& operator=(const valarray<Ty>& right);
valarray<Ty>& operator=(const Ty& val);
valarray<Ty>& operator=(const slice_array<Ty>& slicearr);
valarray<Ty>& operator=(const gslice_array<Ty>& gslicearr);
valarray<Ty>& operator=(const mask_array<Ty>& maskarr);
valarray<Ty>& operator=(const indirect_array<Ty>& indarr);
The first member operator replaces the controlled sequence with a copy of the sequence controlled by
right. The second member operator replaces each element of the controlled sequence with a copy of val.
The remaining member operators replace those elements of the controlled sequence selected by their
arguments, which are generated only by operator[]. If the value of a member in the replacement
controlled sequence depends on a member in the initial controlled sequence, the result is undefined.
If the length of the controlled sequence changes, the result is generally undefined. In this implementation,
however, the effect is merely to invalidate any pointers or references to elements in the controlled sequence.
valarray::operator[]
Ty& operator[](size_t off);
slice_array<Ty> operator[](slice slicearr);
gslice_array<Ty> operator[](const gslice& gslicearr);
mask_array<Ty> operator[](const valarray<bool>& boolarr);
indirect_array<Ty> operator[](const valarray<size_t>& indarr);
Ty operator[](size_t off) const;
valarray<Ty> operator[](slice slicearr) const;
valarray<Ty> operator[](const gslice& gslicearr) const;
valarray<Ty> operator[](const valarray<bool>& boolarr) const;
valarray<Ty> operator[](const valarray<size_t>& indarr) const;
The member operator is overloaded to provide several ways to select sequences of elements from among
those controlled by *this. The first group of five member operators work in conjunction with various
overloads of operator= (and other assigning operators) to allow selective replacement (slicing) of the
controlled sequence. The selected elements must exist.
The first member operator selects element off. For example:
valarray<char> v0("abcdefghijklmnop", 16);
v0[3] = 'A';
// v0 == valarray<char>("abcAefghijklmnop", 16)
The second member operator selects those elements of the controlled sequence designated by slicearr.
For example:
valarray<char> v0("abcdefghijklmnop", 16);
valarray<char> v1("ABCDE", 5);
v0[slice(2, 5, 3)] = v1;
// v0 == valarray<char>("abAdeBghCjkDmnEp", 16)
The third member operator selects those elements of the controlled sequence designated by gslicearr.
For example:
valarray<char> v0("abcdefghijklmnop", 16);