Commit b16c8c8ce42ae4bce2e0b922cd8441f519553a6c

Authored by DarkWingMcQuack
Committed by GitHub
1 parent c2ea58c7

Update TypeTools.hpp (#803)

* Update TypeTools.hpp

fix #802 by using checking `std::ceil(val) == std::floor(val)` instead of `val == static_cast<std::int64_t>(val)` to avoid warnings-

* style: pre-commit.ci fixes

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Showing 1 changed file with 2 additions and 2 deletions
include/CLI/TypeTools.hpp
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 #pragma once 7 #pragma once
8 8
9 // [CLI11:public_includes:set] 9 // [CLI11:public_includes:set]
  10 +#include <cmath>
10 #include <cstdint> 11 #include <cstdint>
11 #include <exception> 12 #include <exception>
12 #include <limits> 13 #include <limits>
@@ -1545,8 +1546,7 @@ inline std::string sum_string_vector(const std::vector&lt;std::string&gt; &amp;values) { @@ -1545,8 +1546,7 @@ inline std::string sum_string_vector(const std::vector&lt;std::string&gt; &amp;values) {
1545 } else { 1546 } else {
1546 if(val <= static_cast<double>((std::numeric_limits<std::int64_t>::min)()) || 1547 if(val <= static_cast<double>((std::numeric_limits<std::int64_t>::min)()) ||
1547 val >= static_cast<double>((std::numeric_limits<std::int64_t>::max)()) || 1548 val >= static_cast<double>((std::numeric_limits<std::int64_t>::max)()) ||
1548 - // NOLINTNEXTLINE(clang-diagnostic-float-equal,bugprone-narrowing-conversions)  
1549 - val == static_cast<std::int64_t>(val)) { 1549 + std::ceil(val) == std::floor(val)) {
1550 output = detail::value_string(static_cast<int64_t>(val)); 1550 output = detail::value_string(static_cast<int64_t>(val));
1551 } else { 1551 } else {
1552 output = detail::value_string(val); 1552 output = detail::value_string(val);