From 448a130c5416be82656dc583e3349b1e1f0ce3cb Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 24 Sep 2026 09:37:27 +0200 Subject: [PATCH] Do not require a default-constructible string_t in the BSON writer GCC 4.9 and MSVC rejected the test's huge_string_t, which has no default constructor; develop never default-constructed string_t here either. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/output/binary_writer.hpp | 6 ++++-- single_include/nlohmann/json.hpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 89b8ce663..ef26732b9 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1368,7 +1368,8 @@ class binary_writer // is in; nothing is allocated unless the document nests bson_frame current(&document); std::vector parents; - string_t index_name; + // string_t need not be default constructible + string_t index_name("", 0); while (true) { @@ -1455,7 +1456,8 @@ class binary_writer bson_frame current(&document); std::vector parents; std::size_t next_size = 0; - string_t index_name; + // string_t need not be default constructible + string_t index_name("", 0); while (true) { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 9716832c1..9d059a01e 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20396,7 +20396,8 @@ class binary_writer // is in; nothing is allocated unless the document nests bson_frame current(&document); std::vector parents; - string_t index_name; + // string_t need not be default constructible + string_t index_name("", 0); while (true) { @@ -20483,7 +20484,8 @@ class binary_writer bson_frame current(&document); std::vector parents; std::size_t next_size = 0; - string_t index_name; + // string_t need not be default constructible + string_t index_name("", 0); while (true) {