When both the left-hand side argument and the right-side one are valarrays, the operation is performed between the corresponding elements in each array (the first element in the left with the first in the right, 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.
The class also overloads operator= and operator[] (see their corresponding references for more info).
Parameters
- val
- Value to use either as left-hand or right-hand operand agains all the elements in the valarray.
T is the template parameter of class valarray (i.e., its elements' type). - lhs
- Left-hand side valarray object.
- rhs
- Right-hand side valarray object.
Return value
For the unary operators, a new valarray object with the modified values.For the compund assignment operators, the left-hand side valarray object.
For the binary operators, a new valarray object with the results of performing the operation.
For the comparison operators, an array of bool elements with the result of the comparisons.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Output:
They are equal. |
See also
| valarray::operator= | Assign content (public member function) |
| valarray::operator[] | Access element or subscript (public member function) |
