cplusplus.com
C++ : Reference : Miscellaneous : valarray : valarray : max
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
valarray
classes:
gslice
gslice_array
indirect_array
mask_array
slice
slice_array
valarray
global functions:
abs
acos
asin
atan
atan2
cos
cosh
exp
log
log10
pow
sin
sinh
sqrt
tan
tanh
valarray
valarray operators
valarray::valarray
valarray::~valarray
member functions:
valarray::apply
valarray::cshift
valarray::max
valarray::min
valarray::operator=
valarray::operator[]
valarray::resize
valarray::shift
valarray::size
valarray::sum


valarray::max

public member function
T max() const;

Return highest value

Returns the maximum value contained in the valarray as if the elements were compared with operator<.

Parameters

none

Return value

The highest value in the valarray.
T is the template type of valarray (the elements' type).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
// valarray::max example
#include <iostream>
#include <valarray>
using namespace std;

int main ()
{
  int init[]={20,40,10,30};
  valarray<int> myvalarray (init,4);
  cout << "The max is " << myvalarray.max() << endl;

  return 0;
}


Output:

The max is 40

See also