mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
4088c0a7f3
Automated register all functions with below naming convention by iterating through the symbols: void DB::registerXXX(DB::FunctionFactory &)
38 lines
843 B
C++
38 lines
843 B
C++
#include <Functions/FunctionFactory.h>
|
|
#include <Functions/FunctionBinaryArithmetic.h>
|
|
#include <Functions/GCDLCMImpl.h>
|
|
|
|
#include <boost/integer/common_factor.hpp>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace
|
|
{
|
|
|
|
struct NameGCD { static constexpr auto name = "gcd"; };
|
|
|
|
template <typename A, typename B>
|
|
struct GCDImpl : public GCDLCMImpl<A, B, GCDImpl<A, B>, NameGCD>
|
|
{
|
|
using ResultType = typename GCDLCMImpl<A, B, GCDImpl, NameGCD>::ResultType;
|
|
|
|
static ResultType applyImpl(A a, B b)
|
|
{
|
|
using Int = typename NumberTraits::ToInteger<ResultType>::Type;
|
|
return boost::integer::gcd(Int(a), Int(b)); // NOLINT(clang-analyzer-core.UndefinedBinaryOperatorResult)
|
|
}
|
|
};
|
|
|
|
using FunctionGCD = BinaryArithmeticOverloadResolver<GCDImpl, NameGCD, false, false>;
|
|
|
|
}
|
|
|
|
REGISTER_FUNCTION(GCD)
|
|
{
|
|
factory.registerFunction<FunctionGCD>();
|
|
}
|
|
|
|
}
|