std::valarray::min(3)

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

πŸ’– NAME πŸ’–

Okay bestie, this is the std::valarray::min(3) page from the C++ Standard Libary manpage set β€” yes, β€œLibary” is literally how it’s written up there, and I’m leaving it exactly as-is πŸ’….

std::valarray::min β€” and the name is literally std::valarray::min. No cap, that’s the whole NAME section.

✨ Synopsis ✨

Signature, served fresh:

T min() const;

This computes the minimum value of the elements. Very β€œfind the smallest one and slay,” lowkey. 🌸

If there are no elements, the behavior is undefined. That’s not a cute mysterious vibe β€” it’s undefined behavior, bestie, so please do not call this on an empty valarray and expect main-character safety. 😭

The function can be used only if operator< is defined for type T. Like, no operator< for T, no min. Periodt. πŸ’…

πŸŽ€ Parameters πŸŽ€

(none) β€” zero parameters. Not a single one. The parameter section is empty and thriving. 🫢

🌸 Return value 🌸

The minimum of the elements. That’s it. That’s the return value. πŸ’–

πŸ¦‹ Example πŸ¦‹

The page says // Run this code, so here’s the exact code:

// Run this code

#include <valarray>
#include <iostream>

int main()
{
    std::valarray<double> a{1, 2, 3, 4, 5, 6, 7, 8};
    std::cout << "Minimum value : " << a.min() << "\n";
}

πŸ“ Output πŸ“

Minimum value : 1

πŸ’œ See also πŸ’œ

  • max β€” returns the largest element (public member function). The iconic opposite-energy bestie to min. πŸ‘‘

That’s the whole page, bestie β€” source: http://cppreference.com, version/date: 2024.06.10. Stay cozy, check your empties, and may your valarray always be non-empty. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from