std::experimental::gcd(3)

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

πŸŽ€ NAME πŸŽ€

std::experimental::gcd(3) β€” okay bestie, this is from the C++ Standard Libary manual, and the NAME entry is literally std::experimental::gcd β€” std::experimental::gcd. Yes, she's named after herself. Main character energy only. πŸ’…

✨ Synopsis ✨

Here's the synopsis, no cap:

Defined in header <experimental/numeric>
template< class M, class N>                          (library
fundamentals TS v2)
constexpr std::common_type_t<M, N> gcd( M m, N n );

It computes the greatest common divisor of the integers m and n. Math, but make it cute. ✨

🫢 Parameters 🫢

  • m, n β€” integer values. That's it. Periodt. 🫢

πŸ’– Return value πŸ’–

If both m and n are zero, it returns zero. Otherwise, it returns the greatest common divisor of |m| and |n|. πŸ’–

🌸 Remarks 🌸

Okay, listen: if either M or N is not an integer type, or if either is (possibly cv-qualified) bool, the program is ill-formed. Not a vibe, but that's the rule. πŸ’€

Also, if either |m| or |n| is not representable as a value of type std::common_type_t<M, N>, the behavior is undefined. That's the scary one, bestie β€” undefined behavior is not it. πŸ™ˆ

πŸ’€ Exceptions πŸ’€

Throws no exceptions. Zero. Nada. She's calm, she's iconic, she's not throwing hands. 🫢

πŸ‘€ See also πŸ‘€

  • lcm β€” constexpr function template returning the least common multiple of two integers (function template). Obsessed with the symmetry. 🌈

Okay that's the whole page! Source: cppreference.com, version/date: 2024.06.10, page: std::experimental::gcd(3). Bye bestie, go find some common ground πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from