diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 312d2e388..20a65d76e 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -1384,21 +1384,21 @@ class serializer } const auto byte = static_cast(value); - char* out = write_buffer.data() + write_buffer_pos; + std::size_t pos = write_buffer_pos; if (byte >= 100) { - *out++ = static_cast('0' + (byte / 100)); - *out++ = static_cast('0' + ((byte / 10) % 10)); + write_buffer[pos++] = static_cast('0' + (byte / 100)); + write_buffer[pos++] = static_cast('0' + ((byte / 10) % 10)); } else if (byte >= 10) { - *out++ = static_cast('0' + (byte / 10)); + write_buffer[pos++] = static_cast('0' + (byte / 10)); } - *out++ = static_cast('0' + (byte % 10)); + write_buffer[pos++] = static_cast('0' + (byte % 10)); - write_buffer_pos = static_cast(out - write_buffer.data()); + write_buffer_pos = pos; } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index b304baab3..567bd68ba 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -22317,21 +22317,21 @@ class serializer } const auto byte = static_cast(value); - char* out = write_buffer.data() + write_buffer_pos; + std::size_t pos = write_buffer_pos; if (byte >= 100) { - *out++ = static_cast('0' + (byte / 100)); - *out++ = static_cast('0' + ((byte / 10) % 10)); + write_buffer[pos++] = static_cast('0' + (byte / 100)); + write_buffer[pos++] = static_cast('0' + ((byte / 10) % 10)); } else if (byte >= 10) { - *out++ = static_cast('0' + (byte / 10)); + write_buffer[pos++] = static_cast('0' + (byte / 10)); } - *out++ = static_cast('0' + (byte % 10)); + write_buffer[pos++] = static_cast('0' + (byte % 10)); - write_buffer_pos = static_cast(out - write_buffer.data()); + write_buffer_pos = pos; } /*!