-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decimal #2846
Decimal #2846
Conversation
template <> struct TypeNumber<Dec128> { static constexpr const size_t value = 18; }; | ||
|
||
template <typename T> | ||
inline constexpr bool decTrait() { return false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is "template variable" in C++17.
Example:
template <typename T> constexpr bool IsNumber = false;
template <> constexpr bool IsNumber<UInt8> = true;
template <> constexpr bool IsNumber<UInt16> = true;
(Core/Types.h)
namespace std | ||
{ | ||
|
||
template <> struct is_signed<__int128> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check both with gcc (libstdc++) and clang (libc++).
It can happen that some std library already have type traits for __int128.
template <> constexpr bool decTrait<Dec128>() { return true; } | ||
|
||
template <typename T> | ||
inline constexpr bool decBaseTrait() { return false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment.
(that it is true for the types that can be used as a storage type for Decimal)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isValidStorageForDecimal
template <> struct TypeNumber<UInt32> { static constexpr const size_t value = 3; }; | ||
template <> struct TypeNumber<UInt64> { static constexpr const size_t value = 4; }; | ||
/// 5 reserved for TypeNumber<UInt128> | ||
template <> struct TypeNumber<Float32> { static constexpr const size_t value = 7; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unusual order: why UInt then Float then Int? Maybe better UInt then Int than Float.
(neat types first)
|
||
template <typename T> | ||
inline constexpr bool decTrait() { return false; } | ||
template <> constexpr bool decTrait<Dec32>() { return true; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isDecimal
function or is_decimal
variable will look better,
because now I can't guess "what trait" by looking at name.
@4ertus2 Not at all! Actually, you should be proud - the code stands out as very high quality and reliable. |
A drawback has been found: #46094 |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en