-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sorted_json_object
doesn't (always?) pass allocator to members_
#485
Comments
I think jsoncons is correct here. jsoncons only supports propagating stateful allocators, including std::pmr::polymorphic_allocator, or a non-propagating stateful allocator wrapped in a std::scoped_allocator_adaptor. Therefore the allocator is automatically propagated in the I believe it would be this constructor that would be called:
|
Thank @danielaparker for the quick reply. I must say that the world of std allocators is new to me, so I'm sorry for filing this issue prior to understanding allocator propagation. Our code looks like this: using JsonType = jsoncons::pmr::json;
json_decoder<JsonType> decoder(
std::pmr::polymorphic_allocator<char>{CompactObj::memory_resource()});
basic_json_parser<char, std::pmr::polymorphic_allocator<char>> parser(
basic_json_decode_options<char>{}, JsonErrorHandler,
std::pmr::polymorphic_allocator<char>{CompactObj::memory_resource()});
parser.update(input);
parser.finish_parse(decoder, ec); Our call stack looks like this:
From which I learn that polymorphic allocator is in fact used to call I'm still learning about allocators world, so I'm not sure what's the best solution (or even if I could do anything on our side to fix this), but perhaps you'd know? Thanks again! |
Yes, you're right, it appears that my understanding of the behaviour of |
Thank you, I appreciate it! |
@chakaz can you check branch main and see if the issue is resolved? |
Indeed! I can confirm that using main I do not see out of allocator behavior, at least not in my use case :) |
Thanks again :) |
I created this small patch: https://github.com/dragonflydb/jsoncons/pull/1/files
But it only handles a couple of cases, but I think that generally any attempt to insert to
members_
should be passing an allocator into it, no?The text was updated successfully, but these errors were encountered: