34#ifndef _GLIBCXX_EXPERIMENTAL_NUMERIC
35#define _GLIBCXX_EXPERIMENTAL_NUMERIC 1
37#pragma GCC system_header
41#if __cplusplus >= 201402L
46namespace std _GLIBCXX_VISIBILITY(default)
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
52inline namespace fundamentals_v2
54#define __cpp_lib_experimental_gcd_lcm 201411
57 template<
typename _Mn,
typename _Nn>
58 constexpr common_type_t<_Mn, _Nn>
59 gcd(_Mn __m, _Nn __n)
noexcept
61 static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
62 "std::experimental::gcd arguments must be integers");
63 static_assert(_Mn(2) == 2 && _Nn(2) == 2,
64 "std::experimental::gcd arguments must not be bool");
67 const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
68 const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
69 return __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
73 template<
typename _Mn,
typename _Nn>
77 static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
78 "std::experimental::lcm arguments must be integers");
79 static_assert(_Mn(2) == 2 && _Nn(2) == 2,
80 "std::experimental::lcm arguments must not be bool");
83 const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
84 const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
85 if (__m2 == 0 || __n2 == 0)
87 _Ct __r = __m2 / __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
89 if _GLIBCXX17_CONSTEXPR (is_signed_v<_Ct>)
90 if (__is_constant_evaluated())
93 bool __overflow = __builtin_mul_overflow(__r, __n2, &__r);
94 __glibcxx_assert(!__overflow);
100_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.
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.
Parallel STL function calls corresponding to stl_numeric.h. The functions defined here mainly do case...