diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index b45004fd4..62a82b47d 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -175,7 +175,7 @@ struct external_constructor j.m_type = value_t::array; j.m_value = value_t::array; j.m_value.array->resize(arr.size()); - if (arr.size() > 0) + if (!arr.empty()) { std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 41c171117..9c4e4a515 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4164,7 +4164,7 @@ struct external_constructor j.m_type = value_t::array; j.m_value = value_t::array; j.m_value.array->resize(arr.size()); - if (arr.size() > 0) + if (!arr.empty()) { std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); }