26#ifndef GUL17_GCD_LCM_H_
27#define GUL17_GCD_LCM_H_
72template <
typename IntTypeA,
typename IntTypeB>
76 static_assert(std::is_integral<IntTypeA>::value
and std::is_integral<IntTypeB>::value,
77 "gcd() arguments must be integers");
79 static_assert(std::is_signed<IntTypeA>::value == std::is_signed<IntTypeB>::value,
80 "gcd() arguments must have the same signedness");
82 using CommonType = std::common_type_t<IntTypeA, IntTypeB>;
126template <
typename IntTypeA,
typename IntTypeB>
130 static_assert(std::is_integral<IntTypeA>::value
and std::is_integral<IntTypeB>::value,
131 "lcm() arguments must be integers");
133 static_assert(std::is_signed<IntTypeA>::value == std::is_signed<IntTypeB>::value,
134 "lcm() arguments must have the same signedness");
136 using CommonType = std::common_type_t<IntTypeA, IntTypeB>;
138 if (
a == 0 &&
b == 0)
auto constexpr bit_set(unsigned bit) noexcept -> ReturnT
Set a bit in an integral type.
Definition bit_manip.h:124
constexpr auto lcm(IntTypeA a, IntTypeB b)
Calculate the least common multiple of two integers.
Definition gcd_lcm.h:128
constexpr auto gcd(IntTypeA a, IntTypeB b)
Calculate the greatest common divisor of two integers using the Euclidean algorithm.
Definition gcd_lcm.h:74
constexpr auto abs(ValueT n) noexcept -> std::enable_if_t< std::is_unsigned< ValueT >::value, ValueT >
Compute the absolute value of a number.
Definition num_util.h:56
Definition of macros used internally by GUL.
Namespace gul17 contains all functions and classes of the General Utility Library.
Definition doxygen.h:29
Declaration of numerical utility functions.