diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index ca4ce98b8..6ea83931b 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3925,7 +3925,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec */ template::value, int>::type = 0> - ValueType value(const json_pointer& ptr, ValueType && default_value) const + typename std::decay::type value(const json_pointer& ptr, ValueType && default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -3937,7 +3937,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec } JSON_INTERNAL_CATCH (out_of_range&) { - return default_value; + return std::forward(default_value); } } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index f6c004e5c..9c67db16d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -21015,7 +21015,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec */ template::value, int>::type = 0> - ValueType value(const json_pointer& ptr, ValueType && default_value) const + typename std::decay::type value(const json_pointer& ptr, ValueType && default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -21027,7 +21027,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec } JSON_INTERNAL_CATCH (out_of_range&) { - return default_value; + return std::forward(default_value); } }