SammyVimes commented on code in PR #1289:
URL: https://github.com/apache/ignite-3/pull/1289#discussion_r1012579902


##########
modules/platforms/cpp/ignite/schema/binary_tuple_builder.h:
##########
@@ -328,18 +446,21 @@ class binary_tuple_builder {
     /**
      * @brief Checks if a value of a given integer type can be compressed to a 
smaller integer type.
      *
-     * @tparam T Source integer type.
-     * @tparam U Target integer type.
+     * @tparam SRC Source integer type.
+     * @tparam TGT Target integer type.
      * @param value Source value.
      * @return true If the source value can be compressed.
      * @return false If the source value cannot be compressed.
      */
-    template <typename T, typename U>
-    static bool fits(T value) noexcept {
-        static_assert(std::is_signed_v<T>);
-        static_assert(std::is_signed_v<U>);
-        using V = std::make_unsigned_t<U>;
-        return (std::make_unsigned_t<T>(value) + std::numeric_limits<U>::max() 
+ 1) <= std::numeric_limits<V>::max();
+    template <typename SRC, typename TGT>
+    static bool fits(SRC value) noexcept {
+        static_assert(std::is_signed_v<SRC>);
+        static_assert(std::is_signed_v<TGT>);
+        using U_TGT = std::make_unsigned_t<TGT>;
+
+        // Check if TGT::min <= value <= TGT::max.
+        return std::make_unsigned_t<SRC>(value + 
std::numeric_limits<TGT>::max() + 1)
+            <= std::numeric_limits<U_TGT>::max();

Review Comment:
   Got it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to