From 80cb607e8cf8ccc7b8fa8fb7ec1eb69b06bc6c67 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 16 Jul 2021 08:08:26 +0200 Subject: [PATCH] :construction: fix return type --- include/nlohmann/json.hpp | 4 ++-- single_include/nlohmann/json.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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;