From 1bd8a102257e21de81bd31036b0959ee3438ba52 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 22 Jul 2021 12:38:48 +0200 Subject: [PATCH] :ok_hand: fix code according to review comments --- include/nlohmann/json.hpp | 6 +----- single_include/nlohmann/json.hpp | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 6af24555b..ca4ce98b8 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3863,7 +3863,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return it->template get::type>(); } - return default_value; + return std::forward(default_value); } JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); @@ -3877,11 +3877,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec detail::is_usable_as_key_type::value > ... > string_t value(const KeyType& key, const char* default_value) const { -#ifdef JSON_HAS_CPP_17 - return value(key, std::string_view(default_value)); -#else return value(key, string_t(default_value)); -#endif } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 6958ece69..f6c004e5c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20953,7 +20953,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return it->template get::type>(); } - return default_value; + return std::forward(default_value); } JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); @@ -20967,11 +20967,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec detail::is_usable_as_key_type::value > ... > string_t value(const KeyType& key, const char* default_value) const { -#ifdef JSON_HAS_CPP_17 - return value(key, std::string_view(default_value)); -#else return value(key, string_t(default_value)); -#endif } /*!