From 2f94d7b9505d540bbfe6dcfcd5ce2d15a87c838b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 10 Oct 2026 00:18:16 +0200 Subject: [PATCH] Give document_data a user-provided constructor Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/document_data.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/nlohmann/detail/view/document_data.hpp b/include/nlohmann/detail/view/document_data.hpp index aa3958e41..13916b577 100644 --- a/include/nlohmann/detail/view/document_data.hpp +++ b/include/nlohmann/detail/view/document_data.hpp @@ -65,7 +65,18 @@ struct document_data } }; - document_data() noexcept = default; + /// user-provided so that the class-type members can be initialized in the + /// member initialization list (-Weffc++ asks for it, and old GCC rejects a + /// defaulted constructor whose exception specification differs from the + /// implicit one); they cannot take default member initializers, which old + /// Clang (3.4-3.6) rejects. The other members have default member + /// initializers. noexcept: create() constructs into raw memory and could not + /// release it if this threw (the std::string default constructors do not + /// allocate). + document_data() noexcept + : arena() // NOLINT(readability-redundant-member-init) + , owned() // NOLINT(readability-redundant-member-init) + {} document_data(const document_data&) = delete; document_data(document_data&&) = delete; document_data& operator=(const document_data&) = delete;