Finds the largest element in a valarray.
Type max( ) const;
Return Value
The maximum value of the elements in the operand valarray.
Remarks
The member function compares values by applying operator< or operator> between pairs of elements of class Type, for which operators must be provided for the element Type.
Example
// valarray_max.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
   using namespace std;
   int i, MaxValue;
   valarray<int> vaR ( 10 );
   for ( i = 0 ; i < 10 ; i += 3 )
      vaR [ i ] =  i;
   for ( i = 1 ; i < 10 ; i += 3 )
      vaR [ i ] =  2*i - 1;
   for ( i = 2 ; i < 10 ; i += 3 )
      vaR [ i ] =  10 - i;
   cout << "The operand valarray is: ( ";
      for (i = 0 ; i < 10 ; i++ )
         cout << vaR [ i ] << " ";
   cout << ")." << endl;
   MaxValue = vaR.max (  );
   cout << "The largest element in the valarray is: "
        << MaxValue  << "." << endl;
}
The operand valarray is: ( 0 1 8 3 7 5 6 13 2 9 ). The largest element in the valarray is: 13.
Requirements
Header: <valarray>
Namespace: std