26 Numerics library [numerics]

26.6 Numeric arrays [numarray]

26.6.2 Class template valarray [template.valarray]

26.6.2.2 valarray constructors [valarray.cons]

valarray();

Effects: Constructs an object of class valarray<T>283 which has zero length.284

explicit valarray(size_t);

The array created by this constructor has a length equal to the value of the argument. The elements of the array are value-initialized ([dcl.init]).

valarray(const T&, size_t);

The array created by this constructor has a length equal to the second argument. The elements of the array are initialized with the value of the first argument.

valarray(const T*, size_t);

The array created by this constructor has a length equal to the second argument n. The values of the elements of the array are initialized with the first n values pointed to by the first argument.285 If the value of the second argument is greater than the number of values pointed to by the first argument, the behavior is undefined.

valarray(const valarray<T>&);

The array created by this constructor has the same length as the argument array. The elements are initialized with the values of the corresponding elements of the argument array.286

valarray(valarray<T>&& v) noexcept;

The array created by this constructor has the same length as the argument array. The elements are initialized with the values of the corresponding elements of the argument array.

Complexity: Constant.

valarray(initializer_list<T> il);

Effects: Same as valarray(il.begin(), il.size()).

valarray(const slice_array<T>&); valarray(const gslice_array<T>&); valarray(const mask_array<T>&); valarray(const indirect_array<T>&);

These conversion constructors convert one of the four reference templates to a valarray.

~valarray();

The destructor is applied to every element of *this; an implementation may return all allocated memory.

For convenience, such objects are referred to as “arrays” throughout the remainder of [numarray].

This default constructor is essential, since arrays of valarray may be useful. After initialization, the length of an empty array can be increased with the resize member function.

This constructor is the preferred method for converting a C array to a valarray object.

This copy constructor creates a distinct array rather than an alias. Implementations in which arrays share storage are permitted, but they shall implement a copy-on-reference mechanism to ensure that arrays are conceptually distinct.