1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-01 13:13:53 +00:00

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>
This commit is contained in:
DarkWingMcQuack 2022-11-21 17:05:04 +01:00 committed by GitHub
parent c2ea58c7f9
commit b16c8c8ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@
#pragma once
// [CLI11:public_includes:set]
#include <cmath>
#include <cstdint>
#include <exception>
#include <limits>
@ -1545,8 +1546,7 @@ inline std::string sum_string_vector(const std::vector<std::string> &values) {
} else {
if(val <= static_cast<double>((std::numeric_limits<std::int64_t>::min)()) ||
val >= static_cast<double>((std::numeric_limits<std::int64_t>::max)()) ||
// NOLINTNEXTLINE(clang-diagnostic-float-equal,bugprone-narrowing-conversions)
val == static_cast<std::int64_t>(val)) {
std::ceil(val) == std::floor(val)) {
output = detail::value_string(static_cast<int64_t>(val));
} else {
output = detail::value_string(val);