55 #ifndef _GLIBCXX_NUMERIC
56 #define _GLIBCXX_NUMERIC 1
58 #pragma GCC system_header
65 #ifdef _GLIBCXX_PARALLEL
78 #if __cplusplus >= 201402L
81 namespace std _GLIBCXX_VISIBILITY(default)
83 _GLIBCXX_BEGIN_NAMESPACE_VERSION
89 template<
typename _Up,
typename _Tp>
93 static_assert(is_unsigned<_Up>::value,
"result type must be unsigned");
94 static_assert(
sizeof(_Up) >=
sizeof(_Tp),
95 "result type must be at least as wide as the input type");
96 return __val < 0 ? -(_Up)__val : (_Up)__val;
99 template<typename _Up>
void __absu(
bool) = delete;
102 template<typename _Tp>
104 __gcd(_Tp __m, _Tp __n)
106 static_assert(is_unsigned<_Tp>::value,
"type must be unsigned");
107 return __m == 0 ? __n
109 : __detail::__gcd(__n, _Tp(__m % __n));
113 template<
typename _Tp>
115 __lcm(_Tp __m, _Tp __n)
117 return (__m != 0 && __n != 0)
118 ? (__m / __detail::__gcd(__m, __n)) * __n
123 #if __cplusplus > 201402L
125 #define __cpp_lib_gcd_lcm 201606
127 #define __cpp_lib_gcd 201606
128 #define __cpp_lib_lcm 201606
131 template<
typename _Mn,
typename _Nn>
132 constexpr common_type_t<_Mn, _Nn>
135 static_assert(is_integral_v<_Mn>,
"std::gcd arguments must be integers");
136 static_assert(is_integral_v<_Nn>,
"std::gcd arguments must be integers");
137 static_assert(_Mn(2) != _Mn(1),
"std::gcd arguments must not be bool");
138 static_assert(_Nn(2) != _Nn(1),
"std::gcd arguments must not be bool");
139 using _Up = make_unsigned_t<common_type_t<_Mn, _Nn>>;
140 return __detail::__gcd(__detail::__absu<_Up>(__m),
141 __detail::__absu<_Up>(__n));
145 template<
typename _Mn,
typename _Nn>
146 constexpr common_type_t<_Mn, _Nn>
149 static_assert(is_integral_v<_Mn>,
"std::lcm arguments must be integers");
150 static_assert(is_integral_v<_Nn>,
"std::lcm arguments must be integers");
151 static_assert(_Mn(2) == 2,
"std::lcm arguments must not be bool");
152 static_assert(_Nn(2) == 2,
"std::lcm arguments must not be bool");
153 using _Up = make_unsigned_t<common_type_t<_Mn, _Nn>>;
154 return __detail::__lcm(__detail::__absu<_Up>(__m),
155 __detail::__absu<_Up>(__n));
160 _GLIBCXX_END_NAMESPACE_VERSION
Parallel STL function calls corresponding to stl_numeric.h. The functions defined here mainly do case...
enable_if< ::__array_traits< _Tp, _Nm >::_Is_swappable::value >::type noexcept(noexcept(__one.swap(__two)))
swap