mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
4088c0a7f3
Automated register all functions with below naming convention by iterating through the symbols: void DB::registerXXX(DB::FunctionFactory &)
44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
#include <Functions/FunctionNumericPredicate.h>
|
|
#include <Functions/FunctionFactory.h>
|
|
#include <base/bit_cast.h>
|
|
#include <type_traits>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
namespace
|
|
{
|
|
|
|
struct IsInfiniteImpl
|
|
{
|
|
static constexpr auto name = "isInfinite";
|
|
template <typename T>
|
|
static bool execute(const T t)
|
|
{
|
|
if constexpr (std::is_same_v<T, float>)
|
|
return (bit_cast<uint32_t>(t)
|
|
& 0b01111111111111111111111111111111)
|
|
== 0b01111111100000000000000000000000;
|
|
else if constexpr (std::is_same_v<T, double>)
|
|
return (bit_cast<uint64_t>(t)
|
|
& 0b0111111111111111111111111111111111111111111111111111111111111111)
|
|
== 0b0111111111110000000000000000000000000000000000000000000000000000;
|
|
else
|
|
{
|
|
(void)t;
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
|
|
using FunctionIsInfinite = FunctionNumericPredicate<IsInfiniteImpl>;
|
|
|
|
}
|
|
|
|
REGISTER_FUNCTION(IsInfinite)
|
|
{
|
|
factory.registerFunction<FunctionIsInfinite>();
|
|
}
|
|
|
|
}
|