diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index c8027233..8f95a797 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3770,7 +3770,7 @@ class basic_json template::value and not std::is_same::value, int>::type = 0> - ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const + ValueType value(const typename object_t::key_type& key, ValueType && default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -3782,7 +3782,7 @@ class basic_json return *it; } - return default_value; + return std::move(default_value); } JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); @@ -3794,7 +3794,7 @@ class basic_json */ string_t value(const typename object_t::key_type& key, const char* default_value) const { - return value(key, string_t(default_value)); + return value(key, std::move(string_t(default_value))); } /*! @@ -3842,7 +3842,7 @@ class basic_json */ template::value, int>::type = 0> - ValueType value(const json_pointer& ptr, const ValueType& default_value) const + ValueType value(const json_pointer& ptr, ValueType && default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -3854,7 +3854,7 @@ class basic_json } JSON_INTERNAL_CATCH (out_of_range&) { - return default_value; + return std::move(default_value); } } @@ -3868,7 +3868,7 @@ class basic_json JSON_HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { - return value(ptr, string_t(default_value)); + return value(ptr, std::move(string_t(default_value))); } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 07a75cca..74f2d09d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -19575,7 +19575,7 @@ class basic_json template::value and not std::is_same::value, int>::type = 0> - ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const + ValueType value(const typename object_t::key_type& key, ValueType && default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -19587,7 +19587,7 @@ class basic_json return *it; } - return default_value; + return std::move(default_value); } JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); @@ -19599,7 +19599,7 @@ class basic_json */ string_t value(const typename object_t::key_type& key, const char* default_value) const { - return value(key, string_t(default_value)); + return value(key, std::move(string_t(default_value))); } /*! @@ -19647,7 +19647,7 @@ class basic_json */ template::value, int>::type = 0> - ValueType value(const json_pointer& ptr, const ValueType& default_value) const + ValueType value(const json_pointer& ptr, ValueType && default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -19659,7 +19659,7 @@ class basic_json } JSON_INTERNAL_CATCH (out_of_range&) { - return default_value; + return std::move(default_value); } } @@ -19673,7 +19673,7 @@ class basic_json JSON_HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { - return value(ptr, string_t(default_value)); + return value(ptr, std::move(string_t(default_value))); } /*!