A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_valarray_max.htm below:

C++ valarray::max Function

C++ valarray Library - Function max Description

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

Declaration

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

T max() const;
C++11
T max() const;
Parameters

none

Return Value

It returns the maximum 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::max function.

#include <iostream>
#include <valarray>

int main () {
   int init[]={10,50,20,90};
   std::valarray<int> myvalarray (init,4);
   std::cout << "The max is " << myvalarray.max() << '\n';

   return 0;
}

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

The max is 90

valarray.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4