C++ valarray Library - Function min



Description

It returns the minimum value contained in the valarray, as if the elements were compared with operator<.

Declaration

Following is the declaration for std::valarray::min function.

T min() const;

C++11

T min() const;

Parameters

none

Return Value

It returns the minimum value contained in the valarray, as if the elements were compared with operator<.

Exceptions

Basic guarantee − if any operation performed on the elements throws an exception.

Data races

All elements effectively copied are accessed.

Example

In below example explains about std::valarray::min function.

#include <iostream>
#include <valarray>

int main () {
   int init[]={20,40,0,30};
   std::valarray<int> myvalarray (init,4);
   std::cout << "The min is " << myvalarray.min() << '\n';

   return 0;
}

Let us compile and run the above program, this will produce the following result −

The min is 0
valarray.htm
Advertisements