34#ifndef _GLIBCXX_EXPERIMENTAL_NUMERIC
35#define _GLIBCXX_EXPERIMENTAL_NUMERIC 1
38#pragma GCC system_header
43#if __cplusplus >= 201402L
48namespace std _GLIBCXX_VISIBILITY(default)
50_GLIBCXX_BEGIN_NAMESPACE_VERSION
54inline namespace fundamentals_v2
56#define __cpp_lib_experimental_gcd_lcm 201411
59 template<
typename _Mn,
typename _Nn>
61 gcd(_Mn __m, _Nn __n)
noexcept
63 static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
64 "std::experimental::gcd arguments must be integers");
65 static_assert(_Mn(2) == 2 && _Nn(2) == 2,
66 "std::experimental::gcd arguments must not be bool");
69 const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
70 const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
71 return __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
75 template<
typename _Mn,
typename _Nn>
79 static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
80 "std::experimental::lcm arguments must be integers");
81 static_assert(_Mn(2) == 2 && _Nn(2) == 2,
82 "std::experimental::lcm arguments must not be bool");
85 const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
86 const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
87 if (__m2 == 0 || __n2 == 0)
89 _Ct __r = __m2 / __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
91#pragma GCC diagnostic push
92#pragma GCC diagnostic ignored "-Wc++17-extensions"
93 if constexpr (is_signed_v<_Ct>)
94 if (__is_constant_evaluated())
96#pragma GCC diagnostic pop
98 bool __overflow = __builtin_mul_overflow(__r, __n2, &__r);
99 __glibcxx_assert(!__overflow);
105_GLIBCXX_END_NAMESPACE_VERSION
typename common_type< _Tp... >::type common_type_t
Alias template for common_type.
ISO C++ entities toplevel namespace is std.
Implementation details not part of the namespace std interface.
Namespace for features defined in ISO Technical Specifications.
constexpr common_type_t< _Mn, _Nn > lcm(_Mn __m, _Nn __n)
Least common multiple.
constexpr common_type_t< _Mn, _Nn > gcd(_Mn __m, _Nn __n) noexcept
Greatest common divisor.