diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-10-20 09:08:07 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-10-20 09:15:50 +0200 |
| commit | 1c69dcbd12c359d5708f4af9d627da97e59d8f0e (patch) | |
| tree | 4f8feac8a658fbcd05dfb3ae979d6eb7ee699333 | |
| parent | 100ca4f3cd27b98a3ffd9bbc51ff2d3433a0d69c (diff) | |
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.
| -rw-r--r-- | src/json.cc | 7 | ||||
| -rw-r--r-- | src/json.hh | 3 |
2 files changed, 6 insertions, 4 deletions
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<int64_t>(value)); +void Writer::value(int32_t value) { this->value(static_cast<int64_t>(value)); } + +void Writer::value(uint32_t value) { + this->value(static_cast<uint64_t>(value)); } std::unique_ptr<Writer> 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; |
