Valarray constructors

Syntax:

    #include <valarray>
    valarray();
    valarray( size_t num );
    valarray( const valarray& c );
    valarray( const TYPE& val, size_t num );
    valarray( const TYPE* p, size_t num );
 
    valarray( const slice_array& c );
    valarray( const gslice_array& c );
    valarray( const mask_array& c );
    valarray( const indirect_array& c );
 
    ~valarray();

The default valarray constructor takes no arguments, creates a new instance of that valarray.

The second constructor creates a valarray with num uninitialzed elements.

The third constructor is a default copy constructor that can be used to create a new valarray that is a copy of the given valarray c.

The fourth constructor creates a valarray with num objects initialized to val. Note that the order of arguments differs from the convention for other standard containers. See the following example for sample usage:

   valarray<int> v1( 42, 5 ); // creates an array of length 5, all with the value 42
   valarray<double> v2( 1.1, 5 ); // creates an array of length 5, all with the value 1.1
   valarray<double> v3( 5, 1.1 ); // error - cannot create length of 1.1!

The fifth constructor creates a valarray or length num and initializes with the values pointed to by the array p.

The sixth constructor creates a valarray from the slice provided by c.

The seventh constructor creates a valarray from the generalized slice provided by c.

The eighth constructor creates a valarray from the mask array provided by c.

The last constructor creates a valarray from the indirect array provided by c.

The default destructor is called for each element when the valarray is destroyed.