[valarray.assign] (original) (raw)

29 Numerics library [numerics]

29.6 Numeric arrays [numarray]

29.6.2 Class template valarray [template.valarray]

29.6.2.3 Assignment [valarray.assign]

valarray& operator=(const valarray& v);

Effects: Each element of the*thisarray is assigned the value of the corresponding element of v.

If the length of v is not equal to the length of *this, resizes *this to make the two arrays the same length, as if by calling resize(v.size()), before performing the assignment.

Postconditions: size() == v.size().

valarray& operator=(valarray&& v) noexcept;

Effects: *this obtains the value of v.

The value of v after the assignment is not specified.

valarray& operator=(initializer_list<T> il);

Effects: Equivalent to: return *this = valarray(il);

valarray& operator=(const T& v);

Effects: Assigns v to each element of *this.

valarray& operator=(const slice_array<T>&); valarray& operator=(const gslice_array<T>&); valarray& operator=(const mask_array<T>&); valarray& operator=(const indirect_array<T>&);

Preconditions: The length of the array to which the argument refers equals size().

The value of an element in the left-hand side of a valarray assignment operator does not depend on the value of another element in that left-hand side.

These operators allow the results of a generalized subscripting operation to be assigned directly to avalarray.