From 1c69dcbd12c359d5708f4af9d627da97e59d8f0e Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 20 Oct 2025 09:08:07 +0200 Subject: json: Avoid ambigous calls to value() int == int32_t on this platform, and a uint32_t fits in both int64_t and uint64_t so be specific. --- src/json.cc | 7 ++++--- src/json.hh | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/json.cc b/src/json.cc index cb9f0b8..46ea513 100644 --- a/src/json.cc +++ b/src/json.cc @@ -289,9 +289,10 @@ class StringWriter : public BaseWriter { void Writer::value(char const* value) { this->value(std::string_view(value)); } -void Writer::value(int value) { - static_assert(sizeof(int) <= sizeof(int64_t)); - this->value(static_cast(value)); +void Writer::value(int32_t value) { this->value(static_cast(value)); } + +void Writer::value(uint32_t value) { + this->value(static_cast(value)); } std::unique_ptr writer(std::string& out) { diff --git a/src/json.hh b/src/json.hh index d872dde..609fc80 100644 --- a/src/json.hh +++ b/src/json.hh @@ -21,7 +21,8 @@ class Writer { virtual void value(bool value) = 0; void value(char const* value); - void value(int value); + void value(int32_t value); + void value(uint32_t value); virtual void start_array() = 0; virtual void end_array() = 0; -- cgit v1.2.3-70-g09d2