diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 3ab316c10..817998c05 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -920,7 +920,7 @@ class binary_writer std::string result; do { - result.push_back(static_cast('0' + n % 10)); + result.push_back(static_cast('0' + (n % 10))); n = static_cast(n / 10); } while (n != 0); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index f26b6683f..cd7269529 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -22655,7 +22655,7 @@ class binary_writer std::string result; do { - result.push_back(static_cast('0' + n % 10)); + result.push_back(static_cast('0' + (n % 10))); n = static_cast(n / 10); } while (n != 0); diff --git a/tests/src/unit-custom-number-types.cpp b/tests/src/unit-custom-number-types.cpp index 787e36557..f9c197574 100644 --- a/tests/src/unit-custom-number-types.cpp +++ b/tests/src/unit-custom-number-types.cpp @@ -34,12 +34,17 @@ class class_int // trivial, like the 128-bit integer classes: the value is stored in a union class_int() = default; - // implicit from built-in integers and explicit from floats, like absl::int128 - template::value, int>::type = 0> - class_int(T v) : value(static_cast(v)) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) - - template::value, int>::type = 0> - explicit class_int(T v) : value(static_cast(v)) {} + // implicit from built-in integers and explicit from floats, like absl::int128; + // non-template overloads (as absl::int128 has) because clang 3.4 and 3.5 + // reject basic_json's defaulted data() for a number type with template + // constructors + class_int(int v) : value(v) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + class_int(unsigned v) : value(v) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + class_int(long v) : value(v) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + class_int(unsigned long v) : value(static_cast(v)) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + class_int(long long v) : value(v) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + class_int(unsigned long long v) : value(static_cast(v)) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + explicit class_int(double v) : value(static_cast(v)) {} template::value, int>::type = 0> explicit operator T() const