allocator in ouput adapter

This commit is contained in:
Alex Fishgait 2023-10-04 07:38:50 +02:00
parent cf81aa75b6
commit cec4a9f2eb
2 changed files with 6 additions and 3 deletions

View File

@ -1110,7 +1110,7 @@ class binary_writer
const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast<std::size_t>(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<string_t>(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<string_t>(std::to_string(array_index++)), el);
}
oa->write_character(to_char_type(0x00));

View File

@ -124,7 +124,10 @@ class output_adapter
public:
template<typename AllocatorType = std::allocator<CharType>>
output_adapter(std::vector<CharType, AllocatorType>& vec)
: oa(std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
{
AllocatorType alloc;
oa = std::allocate_shared<output_vector_adapter<CharType, AllocatorType>>(alloc, vec);
}
#ifndef JSON_NO_IO
output_adapter(std::basic_ostream<CharType>& s)