Commit b16c8c8ce42ae4bce2e0b922cd8441f519553a6c
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 | 7 | #pragma once |
| 8 | 8 | |
| 9 | 9 | // [CLI11:public_includes:set] |
| 10 | +#include <cmath> | |
| 10 | 11 | #include <cstdint> |
| 11 | 12 | #include <exception> |
| 12 | 13 | #include <limits> |
| ... | ... | @@ -1545,8 +1546,7 @@ inline std::string sum_string_vector(const std::vector<std::string> &values) { |
| 1545 | 1546 | } else { |
| 1546 | 1547 | if(val <= static_cast<double>((std::numeric_limits<std::int64_t>::min)()) || |
| 1547 | 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 | 1550 | output = detail::value_string(static_cast<int64_t>(val)); |
| 1551 | 1551 | } else { |
| 1552 | 1552 | output = detail::value_string(val); | ... | ... |