Implement LCM and GCD for C++17. Same code as for Library Fundamentals TS.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276751 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2016-07-26 14:29:45 +00:00
parent f3e7cacb35
commit 1c1e91d9a3
9 changed files with 426 additions and 5 deletions

View File

@@ -2431,7 +2431,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
template<typename _Integral>
inline _LIBCPP_INLINE_VISIBILITY
_Integral
__gcd(_Integral __x, _Integral __y)
__algo_gcd(_Integral __x, _Integral __y)
{
do
{
@@ -2456,7 +2456,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
_VSTD::swap_ranges(__first, __middle, __middle);
return __middle;
}
const difference_type __g = _VSTD::__gcd(__m1, __m2);
const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
for (_RandomAccessIterator __p = __first + __g; __p != __first;)
{
value_type __t(_VSTD::move(*--__p));