diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 80850ab92..fc9e9b774 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -904,7 +904,8 @@ class json_sax_dom_parser : public json_sax_dom_error_state { hashes.push_back(hasher(element.first)); } - ordered_data.key_indexes.emplace_back(new object_key_index(std::move(hashes))); + std::unique_ptr index(new object_key_index(std::move(hashes))); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-unique): std::make_unique is C++14 + ordered_data.key_indexes.push_back(std::move(index)); f.ordered.index = ordered_data.key_indexes.back().get(); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index bb81909ae..50089514f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -16538,7 +16538,8 @@ class json_sax_dom_parser : public json_sax_dom_error_state { hashes.push_back(hasher(element.first)); } - ordered_data.key_indexes.emplace_back(new object_key_index(std::move(hashes))); + std::unique_ptr index(new object_key_index(std::move(hashes))); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-unique): std::make_unique is C++14 + ordered_data.key_indexes.push_back(std::move(index)); f.ordered.index = ordered_data.key_indexes.back().get(); }