Skip to content

Commit 7a6e217

Browse files
committed
Fix constexpr pre-c++20
1 parent f7f9609 commit 7a6e217

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

include/boost/int128/numeric.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ constexpr uint128_t gcd(uint128_t a, uint128_t b) noexcept
272272

273273
if (a > b)
274274
{
275-
std::swap(a, b);
275+
const uint128_t temp {a};
276+
a = b;
277+
b = temp;
276278
}
277279

278280
b -= a;

test/test_gcd_lcm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void test_negative_value()
137137

138138
constexpr int128_t p {2 * 2 * 3};
139139
constexpr int128_t q {2 * 3 * 3};
140-
static_assert(2 * 3 == gcd(p, q));
140+
static_assert(2 * 3 == gcd(p, q), "Wrong");
141141

142142
static_assert(gcd(int128_t{6}, int128_t{10}) == 2, "Wrong");
143143
static_assert(gcd(int128_t{6}, int128_t{-10}) == 2, "Wrong");

0 commit comments

Comments
 (0)