```
void swap(valarray& v) noexcept;
```

*Effects:* *this obtains the value of
v. v obtains the value of *this.

*Complexity:* Constant.

*Returns:* The number of elements in the array.

*Complexity:* Constant time.

This function may only be instantiated for a type T to which operator+= can be applied. This function returns the sum of all the elements of the array.

This function returns the minimum value contained in *this. The value returned for an array of length 0 is undefined. For an array of length 1, the value of element 0 is returned. For all other array lengths, the determination is made using operator<.

This function returns the maximum value contained in *this. The value returned for an array of length 0 is undefined. For an array of length 1, the value of element 0 is returned. For all other array lengths, the determination is made using operator<.

```
valarray<T> shift(int n) const;
```

This function returns an object of class
valarray<T>
of length
size(),
each of whose elements
*I*
is
(*this)[I + n]
if
I + n
is non-negative and less than
size(),
otherwise
T().
Thus if element zero is taken as the leftmost element,
a positive value of n shifts the elements left n
places, with zero fill.

[ *Example:*
If the argument has the value -2,
the first two elements of the result will be value-initialized ([dcl.init]); the third element of the result will be assigned the value
of the first element of the argument; etc.
* — end example* ]
```
valarray<T> cshift(int n) const;
```

This function returns an object of class valarray<T> of length size() that is a circular shift of *this. If element zero is taken as the leftmost element, a non-negative value of n shifts the elements circularly left n places and a negative value of n shifts the elements circularly right -n places.

```
valarray<T> apply(T func(T)) const;
valarray<T> apply(T func(const T&)) const;
```

This member function changes the length of the *this array to sz and then assigns to each element the value of the second argument. Resizing invalidates all pointers and references to elements in the array.