Apache C++ Standard Library User's Guide

## 22.5 Computed Assignment Operators

Class valarray offers two different versions of the following operators: `operator*=()`, `operator/=()`, `operator%=()`, `operator+=()`, `operator-=()`, `operator^=()`, `operator&=()`, `operator|=()`, `operator<<=()`, and `operator>>=()`. In each case, one version takes a valarray reference and the second takes a `T&`. The first version of each operation applies its operation to the corresponding elements of self and the valarray argument. The second version applies the operation to all elements of self using the `T&` argument. For example:

    std::valarray<long> v1(1,3);                     // v1 = {1,1,1}
    std::valarray<long> v2(2,3);                     // v2 = {2,2,2}
    v1 += v2;                                        // v1 = {3,3,3}
    v2 += 2;                                         // v2 = {4,4,4}