From cec4a9f2ebdb8a801a4c947f8368adb1291b257d Mon Sep 17 00:00:00 2001 From: Alex Fishgait Date: Wed, 4 Oct 2023 07:38:50 +0200 Subject: [PATCH] allocator in ouput adapter --- include/nlohmann/detail/output/binary_writer.hpp | 4 ++-- include/nlohmann/detail/output/output_adapters.hpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index d3495a4bb..232e97d5c 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1110,7 +1110,7 @@ class binary_writer const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) { - return result + calc_bson_element_size(std::to_string(array_index++), el); + return result + calc_bson_element_size(static_cast(std::to_string(array_index++)), el); }); return sizeof(std::int32_t) + embedded_document_size + 1ul; @@ -1137,7 +1137,7 @@ class binary_writer for (const auto& el : value) { - write_bson_element(std::to_string(array_index++), el); + write_bson_element(static_cast(std::to_string(array_index++)), el); } oa->write_character(to_char_type(0x00)); diff --git a/include/nlohmann/detail/output/output_adapters.hpp b/include/nlohmann/detail/output/output_adapters.hpp index 630bd8f73..0f5934035 100644 --- a/include/nlohmann/detail/output/output_adapters.hpp +++ b/include/nlohmann/detail/output/output_adapters.hpp @@ -124,7 +124,10 @@ class output_adapter public: template> output_adapter(std::vector& vec) - : oa(std::make_shared>(vec)) {} + { + AllocatorType alloc; + oa = std::allocate_shared>(alloc, vec); + } #ifndef JSON_NO_IO output_adapter(std::basic_ostream& s)