diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index b2b41c76b..b8afa6d37 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -1002,7 +1002,7 @@ class basic_json if ((t == value_t::object && !this->object->empty()) || (t == value_t::array && !this->array->empty())) { std::vector> stack; - stack.push_back(std::make_pair(this, t)); + stack.emplace_back(this, t); while (!stack.empty()) { json_value* value; @@ -1016,7 +1016,7 @@ class basic_json value_t inner_type = inner_value.type(); if ((inner_type == value_t::object || inner_type == value_t::array) && !inner_value.empty()) { - stack.push_back(std::make_pair(&inner_value.m_value, inner_type)); + stack.emplace_back(&inner_value.m_value, inner_type); break; } else @@ -1037,7 +1037,7 @@ class basic_json value_t inner_type = inner_value.type(); if ((inner_type == value_t::object || inner_type == value_t::array) && !inner_value.empty()) { - stack.push_back(std::make_pair(&inner_value.m_value, inner_type)); + stack.emplace_back(&inner_value.m_value, inner_type); break; } else diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a90ae2736..6f6515cad 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -13470,7 +13470,7 @@ class basic_json if ((t == value_t::object && !this->object->empty()) || (t == value_t::array && !this->array->empty())) { std::vector> stack; - stack.push_back(std::make_pair(this, t)); + stack.emplace_back(this, t); while (!stack.empty()) { json_value* value; @@ -13484,7 +13484,7 @@ class basic_json value_t inner_type = inner_value.type(); if ((inner_type == value_t::object || inner_type == value_t::array) && !inner_value.empty()) { - stack.push_back(std::make_pair(&inner_value.m_value, inner_type)); + stack.emplace_back(&inner_value.m_value, inner_type); break; } else @@ -13505,7 +13505,7 @@ class basic_json value_t inner_type = inner_value.type(); if ((inner_type == value_t::object || inner_type == value_t::array) && !inner_value.empty()) { - stack.push_back(std::make_pair(&inner_value.m_value, inner_type)); + stack.emplace_back(&inner_value.m_value, inner_type); break; } else