# 26 Numerics library [numerics]

## 26.6 Numeric arrays [numarray]

### 26.6.2 Class template valarray[template.valarray]

#### 26.6.2.3valarray assignment [valarray.assign]

``` valarray<T>& operator=(const valarray<T>& v); ```

Each element of the *this array is assigned the value of the corresponding element of the argument array. 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.

Postcondition: size() == v.size().

``` valarray<T>& operator=(valarray<T>&& v) noexcept; ```

Effects: *this obtains the value of v. The value of v after the assignment is not specified.

Complexity: Linear.

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

Effects: *this = valarray(il).

Returns: *this.

``` valarray<T>& operator=(const T&); ```

The scalar assignment operator causes each element of the *this array to be assigned the value of the argument.

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

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

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

If the value of an element in the left-hand side of a valarray assignment operator depends on the value of another element in that left-hand side, the resulting behavior is undefined.