From cae9b25074dd58655c74ca39ba4af7d40fe66099 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 14 Jun 2021 06:05:27 +0300 Subject: [PATCH] Minor change --- src/Common/FieldVisitors.h | 6 ------ src/Common/FieldVisitorsAccurateComparison.h | 12 ++++++------ src/Core/Field.h | 6 ++++++ src/Parsers/ASTFunction.cpp | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Common/FieldVisitors.h b/src/Common/FieldVisitors.h index ef593dc6ef9..2f7e24e4fad 100644 --- a/src/Common/FieldVisitors.h +++ b/src/Common/FieldVisitors.h @@ -269,12 +269,6 @@ public: void operator() (const AggregateFunctionStateData & x) const; }; -template constexpr bool isDecimalField() { return false; } -template <> constexpr bool isDecimalField>() { return true; } -template <> constexpr bool isDecimalField>() { return true; } -template <> constexpr bool isDecimalField>() { return true; } -template <> constexpr bool isDecimalField>() { return true; } - /** Implements `+=` operation. * Returns false if the result is zero. diff --git a/src/Common/FieldVisitorsAccurateComparison.h b/src/Common/FieldVisitorsAccurateComparison.h index cf3cbb208dc..0f605b7da23 100644 --- a/src/Common/FieldVisitorsAccurateComparison.h +++ b/src/Common/FieldVisitorsAccurateComparison.h @@ -37,13 +37,13 @@ public: return accurate::equalsOp(l, r); /// TODO This is wrong (does not respect scale). - if constexpr (isDecimalField() && isDecimalField()) + if constexpr (is_decimal_field && is_decimal_field) return l == r; - if constexpr (isDecimalField() && std::is_arithmetic_v) + if constexpr (is_decimal_field && std::is_arithmetic_v) return l == DecimalField(Decimal256(r), 0); - if constexpr (std::is_arithmetic_v && isDecimalField()) + if constexpr (std::is_arithmetic_v && is_decimal_field) return DecimalField(Decimal256(l), 0) == r; if constexpr (std::is_same_v && std::is_arithmetic_v) @@ -86,13 +86,13 @@ public: return accurate::lessOp(l, r); /// TODO This is wrong (does not respect scale). - if constexpr (isDecimalField() && isDecimalField()) + if constexpr (is_decimal_field && is_decimal_field) return l < r; - if constexpr (isDecimalField() && std::is_arithmetic_v) + if constexpr (is_decimal_field && std::is_arithmetic_v) return l < DecimalField(Decimal256(r), 0); - if constexpr (std::is_arithmetic_v && isDecimalField()) + if constexpr (std::is_arithmetic_v && is_decimal_field) return DecimalField(Decimal256(l), 0) < r; if constexpr (std::is_same_v && std::is_arithmetic_v) diff --git a/src/Core/Field.h b/src/Core/Field.h index 9c970fbbb31..2242e8fddae 100644 --- a/src/Core/Field.h +++ b/src/Core/Field.h @@ -162,6 +162,12 @@ private: #pragma GCC diagnostic pop #endif +template constexpr bool is_decimal_field = false; +template <> constexpr bool is_decimal_field> = true; +template <> constexpr bool is_decimal_field> = true; +template <> constexpr bool is_decimal_field> = true; +template <> constexpr bool is_decimal_field> = true; + /// char may be signed or unsigned, and behave identically to signed char or unsigned char, /// but they are always three different types. /// signedness of char is different in Linux on x86 and Linux on ARM. diff --git a/src/Parsers/ASTFunction.cpp b/src/Parsers/ASTFunction.cpp index cc460f600dd..8df3383f487 100644 --- a/src/Parsers/ASTFunction.cpp +++ b/src/Parsers/ASTFunction.cpp @@ -252,7 +252,7 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format NO_SANITIZE_UNDEFINED { using ValueType = std::decay_t; - if constexpr (isDecimalField()) + if constexpr (is_decimal_field) { // The parser doesn't create decimal literals, but // they can be produced by constant folding or the