#include "breeze/mathematics/gcd.hpp" template <typename T> constexpr T gcd(T a, T b)
Returns the greatest common divisor of two integers.
T is not an integral type the program is ill-formed. If the greatest common divisor of
|b| is not representable as a value of type
T, the behavior is undefined.
- If both
bare zero, returns zero. Otherwise it returns the greatest common divisor of
- The intent, for both this template and
breeze::lcm(), was to follow the standard specification (the initial Breeze versions followed the C++ Library Fundamental TS v2, and I meant to update them to C++17 when C++17 would be out). But I soon realized that allowing two different types for the two arguments, and using
common_typefor the result, made everything very hard to reason about (can you tell what the
common_typeof two arbitrary integral types is?). So I decided to stick to what I consider a saner specification.
- Getting Started / Supported compilers