mirror of
https://github.com/nlohmann/json.git
synced 2026-09-13 19:57:58 +00:00
PR #5476 added an unconditional `reserve()` call to the `start_array()` implementations of both `json_sax_dom_parser` and `json_sax_dom_callback_parser`. `ArrayType` is a template parameter of `basic_json`, however, and is not required to have a `reserve()` member function: instantiating either parser for, e.g., `basic_json<std::map, std::deque>` fails to compile, which breaks every use of `parse()` and the binary readers for such a type. Move the capped reservation into a `reserve_array()` helper that selects a no-op overload through `priority_tag` when `ArrayType` has no `reserve()`, mirroring `from_json_object_reserve()`. `std::vector` array types keep reserving as before, and the 16384-element cap is unchanged. Signed-off-by: Niels Lohmann <mail@nlohmann.me> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>