👌 fix code according to review comments

This commit is contained in:
Niels Lohmann 2021-07-22 13:24:23 +02:00
parent 1bd8a10225
commit 3212700eb0
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
2 changed files with 4 additions and 4 deletions

View File

@ -3925,7 +3925,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
*/
template<class ValueType, typename std::enable_if<
detail::is_getable<basic_json_t, ValueType>::value, int>::type = 0>
ValueType value(const json_pointer& ptr, ValueType && default_value) const
typename std::decay<ValueType>::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<ValueType>(default_value);
}
}

View File

@ -21015,7 +21015,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
*/
template<class ValueType, typename std::enable_if<
detail::is_getable<basic_json_t, ValueType>::value, int>::type = 0>
ValueType value(const json_pointer& ptr, ValueType && default_value) const
typename std::decay<ValueType>::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<ValueType>(default_value);
}
}