未验证 提交 bfe50226 编写于 作者: A alexey-milovidov 提交者: GitHub

Merge pull request #6008 from yandex/gcd-lcm-std

Using std::gcd, lcm instead of boost
#include <Functions/FunctionFactory.h> #include <Functions/FunctionFactory.h>
#include <Functions/FunctionBinaryArithmetic.h> #include <Functions/FunctionBinaryArithmetic.h>
#include <boost/integer/common_factor.hpp> #include <numeric>
namespace DB namespace DB
{ {
...@@ -15,7 +16,7 @@ struct GCDImpl ...@@ -15,7 +16,7 @@ struct GCDImpl
{ {
throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<A>::Type(a), typename NumberTraits::ToInteger<B>::Type(b)); throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<A>::Type(a), typename NumberTraits::ToInteger<B>::Type(b));
throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<B>::Type(b), typename NumberTraits::ToInteger<A>::Type(a)); throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<B>::Type(b), typename NumberTraits::ToInteger<A>::Type(a));
return boost::integer::gcd( return std::gcd(
typename NumberTraits::ToInteger<Result>::Type(a), typename NumberTraits::ToInteger<Result>::Type(a),
typename NumberTraits::ToInteger<Result>::Type(b)); typename NumberTraits::ToInteger<Result>::Type(b));
} }
......
#include <Functions/FunctionFactory.h> #include <Functions/FunctionFactory.h>
#include <Functions/FunctionBinaryArithmetic.h> #include <Functions/FunctionBinaryArithmetic.h>
#include <boost/integer/common_factor.hpp> #include <numeric>
namespace DB namespace DB
{ {
...@@ -15,7 +16,7 @@ struct LCMImpl ...@@ -15,7 +16,7 @@ struct LCMImpl
{ {
throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<A>::Type(a), typename NumberTraits::ToInteger<B>::Type(b)); throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<A>::Type(a), typename NumberTraits::ToInteger<B>::Type(b));
throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<B>::Type(b), typename NumberTraits::ToInteger<A>::Type(a)); throwIfDivisionLeadsToFPE(typename NumberTraits::ToInteger<B>::Type(b), typename NumberTraits::ToInteger<A>::Type(a));
return boost::integer::lcm( return std::lcm(
typename NumberTraits::ToInteger<Result>::Type(a), typename NumberTraits::ToInteger<Result>::Type(a),
typename NumberTraits::ToInteger<Result>::Type(b)); typename NumberTraits::ToInteger<Result>::Type(b));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册