std::valarray::max(3)
π NAME π
okay so you opened the std::valarray::max(3) page in the C++ Standard Libary manual, and the NAME section is literally std::valarray::max - std::valarray::max. Self-titled. Main character energy. No notes. π
std::valarray::max β she finds the biggest element and returns it. That's the whole job, and she ate.
β¨ Synopsis β¨
T max() const;
Computes the maximum value of the elements. That's the whole vibe. π
If there are no elements, the behavior is undefined. Genuinely undefined. Like, do not call her on an empty valarray and expect a cute answer β that's not a vibe check, that's a bug. π
The function can be used only if operator< is defined for type T. No operator< for T? Then this function is not invited to the function. Periodt.
π«Ά Parameters π«Ά
None. Zero. Zilch. She takes no parameters. π
π Return value π
The maximum of the elements. Slay. That's it. That's the return value. π
π§ Example π§
// Run this code
#include <valarray>
#include <iostream>
int main()
{
std::valarray<double> a{1, 2, 3, 4, 5, 6, 7, 8};
std::cout << "Maximum value : " << a.max() << "\n";
}
πΈ Output πΈ
Maximum value : 8
π¦ See also π¦
minβ returns the smallest element (public member function). The other half of the duo, iykyk. π
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::valarray::max(3) β bye bestie, go find your max ππβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms