Syntax:
#include <valarray> TYPE max() const;
The max() function returns the largest element value as determined by the '<' operator. If TYPE is not a built-in type, an '<' operator must exist.
This function does not affect the contents of the valarray.
The following code will return the maximum value in the array:
#include <valarray> #include <iostream> const double vd[] = {1,2,3,4,5}; std::valarray<int> v1(vd,5); std::cout << v1.max() << std::endl;
Will produce this output:
5