diff options
author | Treeston <treeston.mmoc@gmail.com> | 2019-08-12 14:33:04 +0200 |
---|---|---|
committer | Treeston <treeston.mmoc@gmail.com> | 2019-08-12 14:33:04 +0200 |
commit | 0a40252c29437672f7d200e347ff6e9d805c3bcf (patch) | |
tree | da9ce1ba919e42d65265cd4b46545ef993615eb0 /src | |
parent | 7378bcb4182cea04d00b74393ba73ce9cb7ea49e (diff) |
i am so done with compilers for today , WHY IS STD::SWAP NOT A CONSTEXPR ASDFOWQWDO (31b5632 7378bcb follow-up grml)
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Utilities/advstd.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/common/Utilities/advstd.h b/src/common/Utilities/advstd.h index d9776b02acb..9663bd91992 100644 --- a/src/common/Utilities/advstd.h +++ b/src/common/Utilities/advstd.h @@ -112,12 +112,13 @@ namespace advstd template <typename T1, typename T2> constexpr std::enable_if_t<advstd::is_unsigned_v<T1> && advstd::is_unsigned_v<T2>, std::common_type_t<T1, T2>> gcd(T1 _m, T2 _n) { - std::common_type_t<T1, T2> n = _n, m = _m; + using T = std::common_type_t<T1, T2>; + T n=_n, m=_m, o; while (n) { - std::swap(m,n); - if (m <= n) - n %= m; + o = m; + m = n; + n = o%n; } return m; } |