1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

Add build step for NVCC and fix a warning (#3227)

* 👷 add step for NVCC build #2676
* 🚨 fix warning (code taken from #2736)
* 👷 use version 2.2.0 of the CI image
This commit is contained in:
Niels Lohmann
2021-12-30 13:40:15 +01:00
committed by GitHub
parent e6bf789f7d
commit 1aca6cb949
6 changed files with 74 additions and 11 deletions

View File

@ -16707,6 +16707,19 @@ class serializer
}
}
// templates to avoid warnings about useless casts
template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value, int> = 0>
bool is_negative_number(NumberType x)
{
return x < 0;
}
template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value, int > = 0 >
bool is_negative_number(NumberType /*unused*/)
{
return false;
}
/*!
@brief dump an integer
@ -16750,12 +16763,11 @@ class serializer
// use a pointer to fill the buffer
auto buffer_ptr = number_buffer.begin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto,cppcoreguidelines-pro-type-vararg,hicpp-vararg)
const bool is_negative = std::is_signed<NumberType>::value && !(x >= 0); // see issue #755
number_unsigned_t abs_value;
unsigned int n_chars{};
if (is_negative)
if (is_negative_number(x))
{
*buffer_ptr = '-';
abs_value = remove_sign(static_cast<number_integer_t>(x));