Commit 20ef31733600c6fbaaa9660297962aee4f940704

Authored by m-holger
1 parent 753b86f9

Refactor `Integer` constructor: replace manual comparisons with `std::cmp_greate…

…r` for cleaner and more concise overflow checks.
libqpdf/qpdf/QPDFObjectHandle_private.hh
... ... @@ -305,10 +305,10 @@ namespace qpdf
305 305 explicit Integer(std::integral auto value) :
306 306 Integer(static_cast<long long>(value))
307 307 {
308   - if constexpr (
309   - std::numeric_limits<decltype(value)>::max() >
310   - std::numeric_limits<long long>::max()) {
311   - if (value > std::numeric_limits<long long>::max()) {
  308 + if constexpr (std::cmp_greater(
  309 + std::numeric_limits<decltype(value)>::max(),
  310 + std::numeric_limits<long long>::max())) {
  311 + if (std::cmp_greater(value, std::numeric_limits<long long>::max())) {
312 312 throw std::overflow_error("overflow constructing Integer");
313 313 }
314 314 }
... ...