Summary
In this episode, Jason introduces two useful mathematical functions added to the C++17 standard library: std::gcd for finding the greatest common divisor and std::lcm for finding the least common multiple of two integers. He demonstrates practical examples, such as calculating that the GCD of 640 and 480 is 160, which reveals a 4:3 aspect ratio. Jason highlights the significant advantage that these functions are implemented as constexpr, allowing the compiler to calculate results at compile time when used with constant expressions, resulting in zero runtime overhead.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[numeric.ops.gcd]40% match -
[numeric.ops.lcm]40% match