Each of this functions performs their respective operation on all the elements in the valarray.

When both the left-hand side argument and the right-side one are valarray objects, the operation is performed between the corresponding elements in each object (the first element of the left one with the first of the right one, the second with the second, and so on...).

When one of the arguments is a value, the operation is applied to all the elements in the valarray against that value.

If the type held in the valarray does not itself support the operation, such an operation shall not be instantiated.

Return value

For the unary operators, a new valarray object with the modified values.
For the compound assignment operators, the left-hand side valarray object.
For the binary operators, a new valarray object with the results of performing the operation on each element.
For the comparison operators, a valarray of bool elements with the result of each of the individual comparisons.

The operators returning a valarray by value are allowed to return an object of a different type instead. Such a type is required to be implicitly convertible to valarray and be supported as argument for all functions taking valarray& arguments. This allows copy-on-write implementations.

Complexity

Iterator validity

No changes: Valid iterators, references and sub-arrays keep their validity.

Data races

All elements in valarray objects involved in the operation are accessed, and -if in a compound assignment- also modified.

Exception safety

If any operation performed on the elements throws an exception, it causes undefined behavior.
If a function fails to allocate storage it needs, it may throw an exception (such as bad_alloc), although this is not mandated.