A valarray object is designed to hold an array of values, and easily perform mathematical operations on them. It also allows special mechanisms to refer to subsets of elements in the arrays (see its operator[] overload).
Most mathematical operations can be applied directly to valarray objects, including arithmetical and comparison operators, affecting all its elements.
The valarray specification allows for libraries to implement it with several efficiency optimizations, such as parallelization of certain operations, memory recycling or support for copy-on-reference / copy-on-write optimizations. Implementations may even replace valarray as the return type for standard functions described below, provided they behave as, and can be converted to, valarray objects.
Template parameters
T
Type of the elements contained in the valarray.
This shall be a value type: i.e., an arithmetic type, a pointer, or a class that behaves like these (such as complex or another level of valarray).