Skip to content

Commit 873513b

Browse files
committed
Use std::gcd (#66)
1 parent 6e1d7fc commit 873513b

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

include/cpp-sort/detail/rotate.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2021 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55

@@ -18,6 +18,7 @@
1818
// Headers
1919
////////////////////////////////////////////////////////////
2020
#include <iterator>
21+
#include <numeric>
2122
#include <type_traits>
2223
#include <utility>
2324
#include <cpp-sort/utility/iter_move.h>
@@ -91,19 +92,6 @@ namespace detail
9192
return r;
9293
}
9394

94-
template<typename Integral>
95-
auto gcd(Integral x, Integral y)
96-
-> Integral
97-
{
98-
do
99-
{
100-
Integral t = x % y;
101-
x = y;
102-
y = t;
103-
} while (y);
104-
return x;
105-
}
106-
10795
template<typename RandomAccessIterator>
10896
auto rotate_gcd(RandomAccessIterator first, RandomAccessIterator middle,
10997
RandomAccessIterator last)
@@ -119,7 +107,7 @@ namespace detail
119107
detail::swap_ranges_inner(first, middle, middle);
120108
return middle;
121109
}
122-
const difference_type g = gcd(m1, m2);
110+
const difference_type g = std::gcd(m1, m2);
123111
for (RandomAccessIterator p = first + g; p != first;)
124112
{
125113
auto t = iter_move(--p);

0 commit comments

Comments
 (0)