diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index cff017725..7d2715300 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3834,7 +3834,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec template < class KeyType, class ValueType, typename detail::enable_if_t < detail::is_getable::value && !std::is_same::value&& detail::is_usable_as_key_type::value > ... > - ValueType value(const KeyType& key, ValueType&& default_value) const + typename std::decay::type value(const KeyType& key, ValueType&& default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -3843,7 +3843,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec const auto it = find(key); if (it != end()) { - return it->template get(); + return it->template get::type>(); } return default_value; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index d787a306d..96c9dd133 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20881,7 +20881,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec template < class KeyType, class ValueType, typename detail::enable_if_t < detail::is_getable::value && !std::is_same::value&& detail::is_usable_as_key_type::value > ... > - ValueType value(const KeyType& key, ValueType&& default_value) const + typename std::decay::type value(const KeyType& key, ValueType&& default_value) const { // at only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -20890,7 +20890,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec const auto it = find(key); if (it != end()) { - return it->template get(); + return it->template get::type>(); } return default_value;