std::valarray::max(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ 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