@@ -627,26 +627,33 @@ constexpr bool is_integral_representable_by(T value)
627627 if constexpr (sizeof (T) == sizeof (U))
628628 {
629629 if constexpr (same_signedness)
630+ {
630631 return true ;
631-
632- if constexpr (std::is_unsigned_v<T>)
632+ }
633+ else if constexpr (std::is_unsigned_v<T>)
634+ {
633635 return value <= static_cast <T>((std::numeric_limits<U>::max)());
634-
635- return value >= static_cast <T>((std::numeric_limits<U>::min)())
636- && static_cast <U>(value) <= (std::numeric_limits<U>::max)();
636+ }
637+ else
638+ {
639+ return value >= static_cast <T>((std::numeric_limits<U>::min)())
640+ && static_cast <U>(value) <= (std::numeric_limits<U>::max)();
641+ }
637642 }
638-
639- if constexpr (sizeof (T) < sizeof (U))
643+ else if constexpr (sizeof (T) < sizeof (U))
640644 {
641645 return static_cast <U>(value) >= (std::numeric_limits<U>::min)()
642646 && static_cast <U>(value) <= (std::numeric_limits<U>::max)();
643647 }
644-
645- if constexpr (std::is_unsigned_v<T>)
648+ else if constexpr (std::is_unsigned_v<T>)
649+ {
646650 return value <= static_cast <T>((std::numeric_limits<U>::max)());
647-
648- return value >= static_cast <T>((std::numeric_limits<U>::min)())
649- && value <= static_cast <T>((std::numeric_limits<U>::max)());
651+ }
652+ else
653+ {
654+ return value >= static_cast <T>((std::numeric_limits<U>::min)())
655+ && value <= static_cast <T>((std::numeric_limits<U>::max)());
656+ }
650657}
651658
652659template <class U = lua_Integer>
@@ -665,18 +672,26 @@ bool is_integral_representable_by(lua_State* L, int index)
665672template <class U = lua_Number, class T >
666673bool is_floating_point_representable_by (T value)
667674{
668- if (std::isnan (value) || std::isinf (value))
669- return true ;
670-
671675 if constexpr (sizeof (T) == sizeof (U))
676+ {
672677 return true ;
678+ }
679+ else if constexpr (sizeof (T) < sizeof (U))
680+ {
681+ if (std::isnan (value) || std::isinf (value))
682+ return true ;
673683
674- if constexpr (sizeof (T) < sizeof (U))
675684 return static_cast <U>(value) >= -(std::numeric_limits<U>::max)()
676685 && static_cast <U>(value) <= (std::numeric_limits<U>::max)();
686+ }
687+ else
688+ {
689+ if (std::isnan (value) || std::isinf (value))
690+ return true ;
677691
678- return value >= static_cast <T>(-(std::numeric_limits<U>::max)())
679- && value <= static_cast <T>((std::numeric_limits<U>::max)());
692+ return value >= static_cast <T>(-(std::numeric_limits<U>::max)())
693+ && value <= static_cast <T>((std::numeric_limits<U>::max)());
694+ }
680695}
681696
682697template <class U = lua_Number>
0 commit comments